Export at the Command Line

Introduction

It is fairly easy to run an export on the command line because Shotcut essentially does the same thing. For example, do an export in the UI and then View > Application > Log… and scroll to the end. You will see the command line printed; however, the file name is fully encoded to workaround potential character set problems.

Quick Start

The general basic form is:

LC_ALL=C melt project.mlt -consumer avformat:export.mp4

Of course, you substitute your own file names possibly with a path prefix for project.mlt and export.mlt. LC_ALL=C sets that environment variable to mitigate problems with numeric strings in some locales. That command line generates a H.264/AAC MP4 using software encoder x264 with melt & FFmpeg’s default encoding options.

Encoding Options

You can add some encoding options at the end of the command line like

LC_ALL=C melt project.mlt -consumer avformat:export.mp4 movflags=+faststart vcodec=h264_vaapi 

Notice that each option is not preceded by one or two dashes. Rather, the -consumer specifies a consumer “object”, and the options that follow until the next dash add properties to that object. There are an extreme number of avformat (named after FFmpeg’s libavformat library) options and values! Moreover, they depend on operating system and which hardware encoders are available. There is a rough reference of them on the MLT web site. If you know or find some ffmpeg command line examples, you can adapt some of its options but not in the same order or syntax! Melt only accepts the encoder and muxer options here, but only some of ffmpeg’s options are for the encoder and muxer. Moreover, ffmpeg command lines do not usually clearly organize the options. So, you need to be a fairly advanced user. See also Advanced Export.

You can use Shotcut’s UI to prepare these option=value pairs. Basically, setup and export, and click the + button at the bottom of the Export > Presets list. That opens a dialog with all of the option=value pairs in a text box. You can copy and paste these, but you need to convert the new lines into spaces.

Project vs. Export Job XML

The above command line uses a -consumer option, but if you looked at Shotcut’s log you see it does not. The difference is that Shotcut adds the consumer and its options into the MLT XML. That is the main difference between them (except for a clip-only project). Basically, Shotcut adds a fourth line to the project XML:

<consumer mlt_service="avformat" movflags="+faststart"… />

So, an easier way to do all of the above is:

  1. Open a project in Shotcut
  2. Click Export
  3. choose export preset or configure export options
  4. Click Export > File
  5. Right-click the new job in Jobs and choose Stop
  6. Right-click the job and choose View XML
  7. In the dialog that opens, choose Save
  8. Choose a location and filename, and click Save
  9. At the command line run LC_ALL=C melt job.xml

Platform Notes

  • With Linux Flatpak, run melt using
    LC_ALL=C flatpak run --command=melt org.shotcut.Shotcut
  • With Linux Snap, run melt using
    LC_ALL=C shotcut.melt
  • With Linux AppImage, I think the only way is to mount the image and then use the reported /tmp directory followed by /usr/bin/melt, for example
    LC_ALL=C /tmp/.mount_shotcuD5hIPg/usr/bin/melt
  • With Linux portable, run melt using
    LC_ALL=C path/to/Shotcut.app/melt
  • With macOS, simply run
    LC_ALL=C /Applications/Shotcut.app/Contents/MacOS/melt
  • On Windows (outside of a package system like msys2), cd to the directory where Shotcut is installed and run melt in CMD.EXE or ./melt in a shell. Alternatively, provide the full path to the melt.exe:
    LC_ALL=C 'C:\Program Files\Shotcut\melt.exe'

:bulb: Pro Tip: Shotcut includes a few other executables you can run in the same manner:

  • ffmpeg
  • ffplay
  • ffprobe
  • glaxnimate
2 Likes