Index of /linux/technotes/mencoder_camera_encoding

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]README.html2006-09-13 17:17 2.7K 
[VID]video_divx_dx50_1000.avi2006-09-13 11:36 4.7M 
[VID]video_divx_dx50_1600.avi2006-09-13 11:25 7.5M 
[VID]video_mjpeg_orig.avi2006-09-13 11:23 36M 
[VID]video_mp42_1000.avi2006-09-13 11:39 4.8M 
[VID]video_mp42_1600.avi2006-09-13 11:27 7.6M 

Compressing Camera videos with mencoder

Compressing Camera videos with mencoder

Cameras like the canon SD550 generate motion jpeg files that are way bigger than they need to be.
This is where you can use mencoder to recompress video to a more efficient format. It gets interesting at this point because you get to pick between a more efficient, better looking Divx format (due to 2 pass encoding) that will not play on windows by default, or a windows format that plays by default for most people, but doesn't look as good for a given bitrate.

With current mencoders, vcodec=mpeg4 generates files with an AVI signature of FMP4, which can't apparently be read on windows, even with the Divx plugin.
The after the fact fix is to binary replace s/FMP4/DX50/ inside the files (2 instances to change), and the files then do play with media player if you have divx installed.
The better fix is to add -ffourcc DX50 on the mencoder command line. Why this isn't a default, I have no idea.

So, to compressed video from camera video clips, you can use one of the following commands:


This offers the better quality/smaller files, but requires the Divx plugin that microsoft will not add to mediaplayer as an auto-retrievable and loadable codec... br=1600 #r="-vop mirror,rotate=x" [x=0..3] for i in 1 2 do mencoder -channels 1 -srate 11025 -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=$br:vpass=$i -ffourcc DX50 \ $r -o "$1".new "$1" done /bin/rm divx2pass.log &>/dev/null


This will generate lesser quality/bigger files, but they work out of the box on windows br=1600 #r="-vop mirror,rotate=x" [x=0..3] mencoder -channels 1 -srate 11025 -oac mp3lame -lameopts mode=3:abr:br=16 \ -ovc lavc -lavcopts vcodec=msmpeg4v2:vhq:vbitrate=$br $r -o "$1".new "$1"


37600170 video_mjpeg_orig.avi

Divx 5 (i.e. mpeg4 for ffmpeg)
 4968830 video_divx_dx50_1000.avi
 7836424 video_divx_dx50_1600.avi

Msmpeg4v2 (works out of the box on windows)
 5057246 video_mp42_1000.avi
 7943084 video_mp42_1600.avi
While size is about the same, in my opinion, the 1000kbps divx5 video looks at least as good as the 1600kbps msmpeg4v2, while the 1600kbps divx5 video looks quite good

You can download the files and compare them for yourself by going here (if they aren't visible in your browser window already)

For now, it seems to mean that one can choose between good quality or windows compatibility. If someone know how to make this better on windows, let me know