10 January 2009

Squeezing videos

Sometimes you just need to squish some videos to fit into single sided DVD of 4,482MB. So if you've got a 1hr video file which is 500MB or so, and would like to reduce the size to about 300MB, use this:
mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=650 -oac copy orig.avi -o squished.avi
Here's a quick rundown of what the flags mean:
-ovc lavc: Use the libavcodec to encode
-lavcopts: sets up the options
vcodec=mpeg4: i.e. Divx
vpass=1: this is not really necessary, but would be useful if you want to re-encode this in the second pass. This generates a file called divx2pass.log, which will be used for vpass=2.
vbitrate=650: here is where I've skipped a stepped, and forced a bitrate for video. Adjust this if you need to squeeze another meg or so.
-oac copy: just copy the audio portion as is.
orig.avi: the original video
-o squished.avi: the squished, output video
This would give something like this:

MEncoder 2:1.0~rc2-0ubuntu17 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3000+ (Family: 15, Model: 47, Stepping: 0)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
AVI file format detected.
VIDEO: [XVID] 608x336 24bpp 23.976 fps 1267.5 kbps (154.7 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:608x336 fps:23.98 ftime:=0.0417
Opening video filter: [expand osd=1]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
audiocodec: framecopy (format=55 chans=2 rate=48000 bits=16 B/s=16000 sample-0)
VDec: vo config request - 608 x 336 (preferred colorspace: Planar YV12)
Movie-Aspect is 1.81:1 - prescaling to correct movie aspect.
videocodec: libavcodec (608x336 fourcc=34504d46 [FMP4])

Pos: 120.3s 2884f ( 4%) 76.31fps Trem: 13min 253mb A-V:0.041 [651:123]


The original file was 576MB, while the re-encoded file is projected to be 253MB and all done 13 minutes!

There are more tricks with MEncoder, and this resource is really useful: "Encoding with MEncoder"

yk.