FAQ

Miscellaneous

Does MLT take advantage of multiple cores? Or, how do I enable parallel processing?

Some of the FFmpeg decoders and encoders (namely, MPEG-2, MPEG-4, H.264, and VP8) are multi-threaded. Set the threads property to the desired number of threads on the producer or consumer. I think the gains are most noticeable on H.264 and VP8 encoding. Next, by default, MLT uses a separate thread for audio/video preparation (including reading, decoding, and all processing) and the output whether that be for display or encoding. Those two capabilities already go a long way. Finally, versions greater than 0.6.2 (currently, that means git master) can run multiple threads for the video preparation! It works using the real_time consumer property:

  • 0 = no parallelism
  • > 0 = number of processing threads with frame-dropping
  • < 0 = number of processing threads without frame-dropping

How can I speed up decoding AVCHD?
  • unfortunately, AVCHD is coded using techniques that prevents FFmpeg from using multiple threads.
  • Passing skip_loop_filter=all to the producer tells FFmpeg to skip the in-loop deblocking filter.
  • Passing skip_frame=bidir to the producer tells FFmpeg to skip bidirectionally codec (B) pictures.
  • For example, melt -profile atsc_1080i_60 00001.mts skip_loop_filter=all skip_frame=bidir
  • It can make a lot of sense to use these options when playing but not when encoding/rendering.

How does the transition filter work?
simple usage is something like: melt file.ogg -track file2.ogg -attach transition:mix start=0.5
more advanced stuff can be done if you hand author XML like:
 <?xml version="1.0" encoding="utf-8"?>
 <mlt title="Audio Mix">
   <producer in="0" out="499">
     <property name="markup">Audio Mix</property>
     <property name="mlt_service">pango</property>
     <property name="meta.fx_cut">1</property>
  <filter mlt_service="transition" transition="mix">
       <property name="start">0.5</property>
     </filter>
   </producer>
 </mlt>
 then the mix can go on it's own track (but needs in/out/length specification of course) like:
 melt file.ogg -track file2.ogg -track mix.mlt out=4999

How do the melt -mix and -mixer options work?

These make it easy to create a transition between the two previous clips. The -mix option specifies the duration of the transition in frame units. Of course, the clips must be at least as long as the transition. The -mixer option specifies the transition to use. You can add more than one. For the example below, with 2 PAL clips, the transition is one second long. The luma transition provides a video dissolve, and the mix transition cross-fades the audio.
melt foo.dv bar.dv -mix 25 -mixer luma -mixer mix:-1

To see the equivalent in XML, use the xml consumer:
melt foo.dv bar.dv -mix 25 -mixer luma -mixer mix:-1 -consumer xml

How can I capture audio and/or video?

Currently, MLT supports what FFmpeg supports. I expect SDI capture to be available by mid 2011. Here are some examples of how to capture using FFmpeg with melt.

The following captures X11 screen ':0.0' at an offset of 100 horizontal, 200 vertical:
melt -verbose -profile hdv_720_25p x11grab::0.0+100,200?width:1280\&height:720

The following captures from video4linux2 and alsa:
melt -verbose -profile quarter_15 alsa:default -track video4linux2:/dev/video0?width:320\&height:240\&frame_rate:15

The following captures from a Firewire digital camera (not DV or HDV, more like an industrial or webcam):
melt -verbose -profile square_ntsc libdc1394:/dev/raw1394?frame_rate:15\&pix_fmt:yuv422

DV and HDV over Firewire or from pipe is not supported!

How do I output audio to PulseAudio, ALSA, or JACK?

Use the SDL consumer - used by default with melt. Then, for PulseAudio or ALSA, first make sure you have installed the appropriate backend, then set an environment variable:
SDL_AUDIODRIVER=pulse melt ... or
SDL_AUDIODRIVER=alsa melt ...

JACK is a little trickier. MLT has a filter named jackrack by which it can send to and/or receive from jackd. You just need to attach the filter to the SDL consumer and tell SDL to not output audio. Here is something roughly equivalent in melt:
melt ... -consumer sdl audio_off=1 frequency=44100 -attach jackrack out_1=system:playback_1 out_2=system:playback_2

The frequency must match whatever jackd is running! The above assumes you want to send to the "system" jack client ports playback_1 and playback_2.

How do I loop something indefinitely on the melt command line?

Set eof=loop before creating any other object such as profile, producer, consumer, filter, track, or transition.

Streaming

After making the experiments below, I have had the most success in reliability, stream integrity, and using higher resolution/framerate/bitrate with Ogg Theora.

How can I stream as Ogg Theora/Vorbis?
  • Install icecast2 and oggfwd, add a mount point in icecast.xml and run icecast followed by
  • melt -profile square_ntsc somevideo.foo ... -consumer avformat real_time=1 terminate_on_pause=0 f=ogg vcodec=libtheora b=1000k acodec=libvorbis aq=25 | oggfwd host 8000 password /live.ogg
  • You can play this with FireFox 3.5+ or VLC using http://host:8000/live.ogg

How can I stream as multicast transport stream?
  • melt -profile square_pal somevideo.foo ... -consumer avformat:udp://224.224.224.224:1234?pkt_size=1316\&reuse=1 real_time=1 terminate_on_pause=0 f=mpegts vcodec=mpeg4 b=1000k s=320x240 acodec=mp2 ab=128k
  • You might change the video codec to h264 or audio codec to libmp3lame or libfaac - if ya got it.
  • You can play this in VLC using udp://@224.224.224.224:1234

How can I stream as transport stream over HTTP?
  • You can convert the multicast above to serve it over HTTP upon request using VLC:
    vlc -I dummy 'udp://@224.224.224.224:1234' --sout '#std{access=http,mux=ts,dst=0.0.0.0:8080}'
  • Finally, you can play it with another VLC using http://host:8080
  • You do not have to use multicast; you can use localhost or a unicast IP address.

How can I stream as something compatible with Windows Media Player over HTTP?

You can transcode the multicast above to serve it over HTTP upon request using VLC:
vlc -I dummy 'udp://@224.224.224.224:1234' --sout \
'#transcode{vcodec=WMV2,vb=800,acodec=wma2,ab=128,channels=2,samplerate=44100}:std{access=http,mux=asf,dst=0.0.0.0:8080}'

Filters

Can frei0r and LADSPA effects be added as filters in the XML?

Yes, but the ladspa filter currently requires an external xml file defining one or more ladspa filters. Eventually, it would be nice to be able to embed this in the MLT XML - for example, you can embed SVG in the pixbuf producer. This external xml file is the format generated by the JACK Rack program. You might take a look at the JACK Rack (requires jack sound daemon) UI and design something similar. Below is a sample jackrack XML file:

<?xml version="1.0"?>
<!DOCTYPE jackrack SYSTEM "http://purge.bash.sh/~rah/jack_rack_1.2.dtd">
<jackrack>
 <channels>2</channels>
 <samplerate>48000</samplerate>
 <plugin>
   <id>1217</id>
   <enabled>true</enabled>
   <wet_dry_enabled>false</wet_dry_enabled>
   <wet_dry_locked>true</wet_dry_locked>
   <wet_dry_values>
     <value>1.000000</value>
     <value>1.000000</value>
   </wet_dry_values>
   <lockall>true</lockall>
   <controlrow>
     <lock>true</lock>
     <value>25</value>
     <value>25</value>
   </controlrow>
   <controlrow>
     <lock>true</lock>
     <value>0.75</value>
     <value>0.75</value>
   </controlrow>
   <controlrow>
     <lock>true</lock>
     <value>0.69</value>
     <value>0.69</value>
   </controlrow>
   <controlrow>
     <lock>true</lock>
     <value>1</value>
     <value>1</value>
   </controlrow>
 </plugin>
</jackrack>

Pass the filename to a generated jackrack xml file to the filter's resource property.

Does MLT know anything about the LADSPA and frei0r effects, such as which parameters are needed, valid values, etc.?

There is something called LADSPA RDF that contains metadata about the filters and their parameters. Command line tool `listplugins` lists the ladspa plugins. Command line tool 'analyseplugin' shows the parameters for a plugin. You might be able to find a python binding to liblrdf or a pure python RDF parser to parse the RDF yourself. Or, maybe just run these and parse their output.

MLT features a metadata system similar to LADSPA that uses YAML Tiny instead of RDF format, but the query tool is built into melt. Not all MLT services support this yet, but frei0r does. 'melt -query filters' shows all of the filters. 'melt -query filter=frei0r.pixeliz0r' shows the metadata including parameters. There is an API for this metadata - see mlt++/MltRepository.h. There are frei0r producers and transitions as well.

Finally, along the same lines, there is a sox filter for additional audio effects. Run 'sox --help' to see a list of effects. Then, run 'sox --help-effect=echo' for the information on the effect parameters.

How can I burn timecode into the video?

Here is an example command line:
melt foo.mp4 meta.attr.titles=1 meta.attr.titles.markup=#timecode# -attach data_show dynamic=1

If you want to burn the frame number then use #frame# instead of #timecode#.

How to center a text in a video?

melt colour:red -filter watermark:"+LinuxTag~Flop Bobber.txt" composite.progressive=1 producer.align=centre composite.valign=c composite.halign=c

When changing the font for pango it is rather small.
  • Use the producer.size property
  • melt colour:red -filter watermark:"+Flop.txt" composite.progressive=1 producer.font="DIN-Light" producer.size=48

How to repeat the very first frame of a video for 200 frames?
  • The split can be used here together with swap, that reverses frame order
  • melt file -split 0 -swap -repeat 200 -swap
  • -split 0 is the first frame, -swap reverses frame order so it becomes last frame, repeat operates on the last frame, swap restores original frame order
  • Another approach: melt file.avi out=0 -repeat 200 file.avi in=1
  • The newer approach is to use the 'freeze' filter. Set the frame property to the number of the frame. Then, set either freeze_before or freeze_after =1.

How to reverse a movie, e.g. have it playing backward?
  • Somewhat awkward: Create jpgs for each frame and make movie in reverse order
  • melt INPUT.VIDEO -consumer avformat:images%05d.jpg real_time=0
  • melt -group in=0 out=0 `ls -r` -consumer avformat:reverse.mpeg qscale=0.01 real_time=0
  • Warning: If the argument list gets to long this might not work?
  • The newer approach is to use the framebuffer producer and append '?-1' to the file name.

Is it possible to do multiple composites?

On 2005-06-26 the following example was working:
melt colour:blue -attach watermark:"+hello.txt" producer.size=266 composite.alpha_a=0 -attach watermark:colour:red composite.alpha_b=0 composite.or=1

How do you normalize audio?
You need version 0.7.6+ and the sox filter to normalize audio over a file or multiple files. Then, you need to run an analysis step:

melt test.wav -filter sox:analysis  -consumer xml:test.mlt video_off=1 all=1

This outputs the replay gain level into MLT XML file test.mlt. Then, when you play test.mlt, it applies the gain.

Topic revision: r29 - 2012-01-25 - 18:06:01 - DanDennedy
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding MLT Wiki? Send feedback