Playing and editing audio-visual from the command line

Melt

Lead Image © Okea, 123RF.com

Lead Image © Okea, 123RF.com

Article from Issue 206/2018
Author(s):

Whether you are an expert or a beginner, you can learn to edit audio and video clips at the command line with Melt.

When free software users think of Melt, they usually think first of GCC MELT [1], the popular extension system to the GCC compiler. However, Melt, the command-line multimedia player [2], is just as interesting in its own right, because it supports every file format you can imagine, and probably a few that you haven't. Admittedly, Melt's non-standard syntax takes a bit of learning, but as a command, it can be as simple or as complex as you choose to make it.

Melt is part of the Media Lovin' Toolkit (MLT) [3], a cross-platform multimedia framework designed for television. Two characteristics make Melt stand out: First, it has few dependencies, and, second, it works with existing multimedia libraries and applications. These characteristics are possible because of Melt's modular design and its high-level bindings for major programming languages like C++, Java, Lua, Perl, PHP, Python, Ruby, and Tcl. Additionally, Melt is thoroughly modern, making use of multicore processors and GPU processors.

Functionally, Melt is a full-featured editor that can customize both audio and video clips in detail, either for one-time playback or for permanent changes. Strictly speaking, Melt was originally a test tool for the MLT framework. However, its versatility means that, in a few small circles, Melt has become that most free software of applications: A command-line tool for purposes that are usually expected only in a desktop environment. These days, Melt is often found by itself in the repositories of major distributions.

Basic Playback

Like most commands at the prompt, Melt begins simply enough. To play a video, audio, or audiovisual clip, enter:

melt CLIP

A window opens for the video. It will be blank for an audio-only file and, of course, have no sound for a video-only file. When all clips have played, regardless of their format, you will have to close the window manually (Figure 1).

Figure 1: Melt opens a window in which to run a video.

Multiple files can be entered with a space between them. Options for each file follow immediately after its name. Alternatively, you can use -group immediately after the basic command to apply options to all the listed files. For example,

melt -group in=0 out=25 CLIP1 CLIP2

will play the first 25 frames of CLIP1 and then the first 25 frames of CLIP2. Deciding exactly which frames to play, of course, requires some experimentation.

The group settings apply until the next -group option is entered in the command, so if you want to play the first 25 frames of CLIP1 followed by the whole of CLIP2, the command would be:

melt -group in=0 out=25 CLIP1 -group CLIP2

In effect, this command creates a new, empty group for the second clip. However, you could add a different range of frames to play for the second clip:

melt -group in=0 out=25 CLIP1 -group in=35 out=60 CLIP2

When playing an audiovisual clip, you can play the audio only by using either -audio-track or -hide-video. Conversely, -video-track or -hide-audio plays the video portion of a clip without the accompanying sound.

Besides in= and out=, you can modify playback with several other options. If you are experimenting with exactly what frames to use with in= and out=, adding -progress will give you a graphical representation of the file that is currently playing. You can also loop playback with -repeat TIMES.

Services and Filters

For simple playback, the options listed above are usually enough. However, the melt command also includes a wealth of advanced options for what the MLT documentation refers to as "services."

If you want to add a service to all the clips specified in the command, enter

-group -filter SERVICE

at the end of the command. For instance, to play all the clips in the same directory without color, enter:

melt -group in=0 out=25 CLIP1 -group in=35 out=60 CLIP2 -group -filter greyscale

Do not forget to include -group, or else the service may be affected by options for the last-named clip.

However, if you want the service to be used only by a specific clip, enter the option

-attach SERVICE:ARGUMENT NAME=VALUE

after the clip, just as you would any other option.

Melt supports hundreds of services, so you might often want to run the -query option first to see what services are available. To reduce the length of the output, you can run

melt -query SERVICE-TYPE

to see a group of related services (Figure 2). Even then, you will probably want to filter the command with |less to make it readable.

Figure 2: The start of the list of audio formats supported by Melt, as shown by the query option.

Note, too, that many services are listed by -query with a prefix, although all filters are entered in a melt command without the prefix. Additionally, the bare list may not tell you very much, so after you locate a possibly useful service, run

-query SERVICE = ID

to receive more detailed information about the arguments and values that a particular service supports. If more detailed information is not available for a service, Melt simply displays the list of available services, organized by type.

The following service types can modify the -query option:

  • "consumers": The application or utility that plays clips, such as XML or JACK. If no consumer is specified, the default is SDL.
  • "filters": Frame modifiers that change how audio or visual are displayed. No filter affects the files – only how they are displayed. Examples include saturation, volume, and watermark.
  • "producers": Software playback libraries or components, or else wrappers for hardware drivers.
  • "transitions": How playback moves from one clip to another – for instance, luma, a change in brightness achieved by specifying a grayscale bitmap, or matte, a brief overlay of the two clips. When adding a transition to a command, use -mix LENGTH to set its duration, followed by -mixer TRANSITION.
  • "profiles": How a clip is processed, such as the frame resolution and scan rate. If not specified, the characteristics of the clips themselves are used. Beginners can generally ignore these services.
  • "presets": Playback options and formats. Again, beginners might want to ignore these services.
  • "formats": Audio, video, and audiovisual formats supported by Melt. Formats can be specified to force Melt to use a clip when it is having trouble identifying its format. Many listed formats are likely to be known only by experts.
  • "audio_codecs": Audio formats supported by Melt. Use this setting with -query rather than formats to reduce the size of the list displayed.
  • "video_codecs": Video formats supported by Melt. Use this setting with -query rather than formats to reduce the size of the list displayed.

Unless otherwise specified above, you can run any of these types of service, by entering the name of the type followed by the service (e.g., -process NAME).

Although Melt can be run with only a basic knowledge of its command structure, these lists of services reveal exactly how complex the command can be. Very likely, the average user does not use half of the available services, but if you are an expert in audio-video matters, Melt can probably accommodate your needs as well as those of a beginner.

Last Words

As you can imagine, the melt command can be complex by the time you are finished. Any given instance can quickly become so complex that recreating its structure may be more than you are eager to attempt. You can always use Bash history, but in the long run, you can save the command structure with:

-serialise FILENAME.melt

To play back the saved command structure, run it in Melt as though it is just another supported format. You can add another clip by including -track CLIP to the same command.

Advanced users may want to learn about MLT's XML format [4], which uses the same components as the melt command to save complex playback options. Note, though, that the online MLT documentation presupposes a knowledge of audiovisual matters and might be only intermittently useful, unless you are willing to look elsewhere constantly for definitions or to experiment until you understand.

Most users, though, should find a basic knowledge of Melt more than enough to begin using it. Like all audiovisual editors, including those that run on the desktop, Melt is very much what you make it. The MLT website admits to a few gaps in functionality, such as the ability to add a watermark to every frame. However, for the most part, Melt can meet the needs of not only users who want nothing more than simple playback, but also more advanced users who want to edit playback in more elaborate ways.

The Author

Bruce Byfield is a computer journalist and a freelance writer and editor specializing in free and open source software. In addition to his writing projects, he also teaches live and e-learning courses. In his spare time, Bruce writes about Northwest coast art. You can read more of his work at http://brucebyfield.wordpress.com

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Video Editor Roundup

    In a comparison test, we checked out nine free video editing programs: Cinelerra, Flowblade, Kdenlive, Kino, Lightworks, LiVES, OpenShot, Pitivi, and Shotcut.

  • Downloading Web Video

    With the right tools, you can store YouTube movies on your hard disk and view them when Internet access is unsatisfactory or unavailable.

  • Tutorials – FFmpeg Devices

    FFmpeg is good not only for converting and fusing videos together, it can also generate streams on the fly, which you can then use for compositing and effects.

  • Gobbling Up

    Most video editors supply you with a generic catalog of transitions, usually in the shape of tired wipes and fades. But what if you wanted something a little more special? FFmpeg to the rescue.

  • Web Videos

    We’ll show you how to convert your videos to FLV format and play them from your website with FlowPlayer.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News