Playing and editing audio-visual from the command line
Melt
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).
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.
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, ormatte
, 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 thanformats
to reduce the size of the list displayed."video_codecs"
: Video formats supported by Melt. Use this setting with-query
rather thanformats
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.
Infos
- GCC MELT: http://gcc-melt.org/
- Melt: https://www.mltframework.org/docs/melt/
- Media Lovin' Toolkit: https://www.mltframework.org
- MLT XML: https://www.mltframework.org/docs/mltxml/
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.