Mplayer / Mencoder Tips

I love mplayer and mencoder, they just do everything I want to be able to do with video / audio.

Here are the commands I use on a regular basis to be productive and get my media sorted.

1. To stick two or more pieces of video together into one file (all the same codec/resolution etc)

mencoder -ovc copy -oac copy -o output.avi 1st.avi 2nd.avi 3rd.avi

2. Similarly, to rewrite an index on a broken avi file

mencoder -idx input.avi -ovc copy -oac copy -o output.avi

3. Simple conversion of DVD to avi

mencoder dvd://1 -dvd-device /path/to/input/directory/ -o output.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4

and another dvd rip one liner

mencoder dvd://1 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=”1200″ -vop scale -zoom -xy 640 -oac mp3lame -lameopts br=128 -o dvd.avi

4. Extract the audio stream from a video

mplayer -dumpaudio -dumpfile audio.mp3 video_source.mpg (can use ac3 instead of mp3)

or using mencoder

mencoder video.avi -oac mp3lame -of rawaudio -ovc frameno -o soundtrack.mp3

5.Testing for cropping

mplayer test.avi -vf cropdetect
This then settles to give an output like this:
crop=688:448:2:54
enter these values as required

6. Samples for encoding an mpg to avi

mencoder input.mpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect -oac copy -vf crop=528:560:96:8 -o output.avi
Notes:
Only crop if necessary
different bitrates can be set using vbitrate=1500 for example, default is 900 (?)
resample audio if required using acodec=mp3 abitrate=192 for example (remove the word copy after -oac
mencoder input.mpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect vbitrate=1500 -oac lavc acodec=mp3:abitrate=128 -vf crop=528:560:96:8 -o output.avi
mencoder input.mpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect -oac lavc -vf crop=528:560:96:8 -o output.avi

7. To cut a section from a captured file

mencoder capture.mpg -ss 01:33:40.68 -endpos 04:36 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect -oac copy -vf crop=688:448:2:54 -o cut.avi
Notes:
-ss is hh:mm:ss.hs start position from beginning of main capture.avi
-endpos is hh:mm:ss of film to capture, so the above will cut 4.5 minutes.
The original file is not damaged
This encodes from raw mpeg2 to mpeg4.avi
alt – cuts but with a direct stream copy
mencoder input.avi -ss 00:01:32 -endpos 01:00:00 -ovc copy -oac copy -o output.avi

8.To play dvb tv using mplayer

mplayer dvb://
To record dvb tv using mplayer to ts file
mplayer -dumpfile bbc1.ts -dumpstream dvb://”BBC One”
Notes:
Channel name is important and must match those in channels.conf

Leave a Reply

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