Mencoder… Shalalala – I am loving it ;)!

Hi all.

Mencoder? What is mencoder…

Command:

man mencoder

says it all…

Mencoder (MPlayer’s Movie Encoder) is a simple movie encoder, designed to encode MPlayer-playable movies (see above) to other MPlayer-playable formats (see below). It encodes to MPEG-4 (DivX/Xvid), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio in 1, 2 or 3 passes. Furthermore it has stream copying abilities, a powerful filter system (crop, expand, flip, postprocess, rotate, scale, noise, RGB/YUV conversion) and more.

The truth is that mencoder tool is so POWERFUL that its man page is a size of a book… The truth is – I don’t really know mencoder – I am using only a fraction of its possibilities. I am going to share here what I have learned over the last two years. It’s not much – but the knowledge has served me well.

From any format to PSP mp4 format:

mencoder /path/to/input.file -oac lavc -ovc lavc -of lavf -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=384:acodec=libfaac -af lavcresample=24000 -vf scale=368:208,harddup -lavfopts format=psp -ofps 15 -o /path/to/file.mp4

Add music to the video file:

mencoder -ovc copy -audiofile /path/to/file.mp3 -oac copy /path/to/nosound.avi -o /path/to/filewithmusic.avi

Resize to the 320 x 240 resolution:

mencoder /path/to/input.avi -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -vf scale=320:240 -o /path/to/output.avi

Join 2 files into 1:

mencoder -forceidx -ovc copy -oac copy -o /path/to/joined.avi /path/to/part_1.avi /path/to/part_2.avi

AVI to FLV (Flash Video):

mencoder -forceidx -of lavf -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=250:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=360:240 -o /path/to/output.flv /path/to/source.avi

Any video to AVI:

mencoder /path/to/input.file -o /path/to/file.avi -ovc lavc -oac pcm

Extract soundtrack from the video file:

mplayer -dumpaudio /path/to/video.file -dumpfile /where/to/save/file.mp3

Remove the current audio track (creates silent video):

mencoder -ovc copy -nosound /path/to/withsound.avi -o /path/to/withoutsound.avi

Speed up video x times:

mencoder -o /path/to/faster.avi -speed 4 -ofps 25 -vf framestep=2 -ovc lavc -lavcopts vcodec=mpeg4 /path/to/normal/pace.avi

Change the value of -speed to 2 if the output is to fast. Change the value of framestep= to drop more or less frames in the process.

Rotate video X degrees:

mencoder -vf rotate=1 -o /path/to/rotated/output.avi -oac copy -ovc lavc /path/to/input.avi

In this case the video is rotated 90 clockwise. Change the value of rotate= to achieve different values.

Hope someone finds it useful someday.

Andy

Advertisements