Useful Mplayer/Mencoder Commands

mplayer/mencoder are powerful tools. This is a list of useful mplayer/mencoder commands.

Extract the audio, convert it to PCM and write the resulting wave file to audio.wav:

mplayer -vo null -hardframedrop -ao pcm:file=audio.wav video.avi

Convert .wav file to .mp3 file:

lame -h out.wav out.mp3

Preview a video composed of all jpeg files from the current folder at 15fps:

mplayer "mf://*.jpg" -mf fps=15

Create a 15fps video from all jpeg files of the current folder:

mencoder "mf://*.jpg" -mf fps=15 -ovc lavc -o ./output.avi

Cut a video from second 6 to second 206 (which is 200+6, the output.avi is 200 seconds long):

mencoder big-file.avi -ss 6 -endpos 200 -ovc copy -oac copy -o output.avi

Convert raw videos into ISO standard MPEG-4 (DivX 5, XVID compatible) videos:

mencoder source.avi -ovc lavc -oac lavc -ffourcc DX50 -lavcopts 
 vcodec=mpeg4:vbitrate=400:v4mv:mbd=2:trell:autoaspect:dia=2:acodec=mp3:abitrate=32:vpass=1 
 -vf hqdn3d -o output.avi

Get informations about a video:

mplayer -frames 0 -identify ./video.avi

Show all mplayer filter list:

mplayer -vf help

Play audio files over ssh connection

ssh user@example.com "cat audio.mp3" | mplayer -cache 8192 -

Play files from FTP:

wget ftp://example.com/file.avi -O - | mplayer -cache 8192 -

Repeat a file multiple times:

mplayer file1 -loop 2 file2 -loop 1 file3 -loop 4

Record stream:

mplayer -dumpstream -dumpfile output.rm -cache 4096 rtsp://example.com/file.rm

Update history:
Jun 23, 2010. Correct the errors about vcodec and endpos options.

About Eric Zhiqiang Ma

Eric Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed systems and etc. Also find Eric on Facebook, Twitter, LinkedIn and Google+. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties. More Posts - Website

0 thoughts on “Useful Mplayer/Mencoder Commands”

Leave a Reply

Your email address will not be published. Required fields are marked *

58 + = sixty five

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Click to subscribe to Fclose.com Posts by Email if you have not.