[MPlayer-users] Which codec is fast and good?

LGW large at lilymarleen.de
Mon Aug 25 18:29:17 CEST 2003

Rainer Hantsch wrote:

>[Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
>I want to record TV shows on the fly (realtime) into a usual video file which
>can be played with XINE and/or mplayer.
>Meanwhile I have the puzzle of my Linux TV-Recorder to 2/3 complete:
>a.) I can tune a TV-station and set color saturation, and so forth with
>    v4lctl. (Thanks for pointing me to this utility, it is great.)
>b.) I can basically record to _one_ file, either as 'mjpg' or 'divx'.
>My problem is to find a good codec and data compression to get the best
>possible picture at an acceptable file size, but without framedrops.
>Using mjpeg as video encoding, my celeron 1700 has no problems with recording,
>I can constantly see 25fps here, but I get extreme file size (10 minutes = 650
>MB). So I am afraid that this will cause problems afterwards when recording a
>full length movie.
>This is what I do in this case:
>mencoder -tv \
>audiorate=48000:amode=1:forcechan=2:adevice=/dev/dsp \
>-oac mp3lame -lameopts cbr:br=128 \
>-ovc lavc -lavcopts vcodec=mjpeg:vqscale=3 \
>-vop crop=701:576,denoise3d=8:6:6,pp=md \
>-endpos $dauer \
>-o video1.mpg
>Using mpeg4 and divx gives much smaller file size and good quality, but I get
>often only 24fps, so mencoder starts dropping frames after a while. Not what I
>This is what I do here (I already reduced the image size a little bit, so I
>get it without frame drops, but the result is not so good):
>mencoder -tv \
>audiorate=48000:amode=1:forcechan=2:adevice=/dev/dsp \
>-oac mp3lame -lameopts cbr:br=128 \
>-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900 \
>-vop denoise3d=8:6:6,pp=md \
>-endpos $dauer \
>-o video1.avi
>I guess that DivX simply causes too much CPU load.
>Is there another codec who gives good compression with a minimum of CPU load?
>I will accept any file format which can be converted afterwards into a useful
>file format, as long as this causes no additional quality loss.
>  Ing. Rainer Hantsch
Try using another input resolution for the v4l device, some cards (as my 
wintv pci) have problems scaling to some resolutions. It's no problem to 
let the scaling to mencoder. The best thing would be to use full PAL 
resolution for the capture process, and use the deinterlacer of mencoder 
(smaller files, better looking) prior to the scaling.

Remember that higher resolutions need higher bitrates, and you won't get 
that much quality out of mpeg4 if you use one-pass-encoding (which you 
must, as it's realtime ;) - I mostly use half PAL resolution (352*xxx) 
to get better results.

MPEG4 is definitly no that much of a problem for the CPU, I could record 
half PAL on my old Duron700 with minimal frame drops (one per ten 
minutes or so). Also make sure that your v4l device uses DMA and is not 
pulled through I/O channels (bttv uses DMA, and most other drivers 
should so, too...)

Some examples from my machine (2600+ Athlon XP):
1/2 PAL, vhq mpeg4/lavc: 15% CPU
full PAL, vhq mpeg4/lavc, bitrate 14000 (!): 85% CPU...

I hope you get it working. Also make sure that your mencoder is 
optimized for your CPU. There is also an lavcopt for realtime encoding, 
it should tell him to drop quality instead of frames. But that changed 
with the latest version, so I'm not sure what it's called.


>RTFM!!!  http://www.MPlayerHQ.hu/DOCS
>Search:  http://www.MPlayerHQ.hu/cgi-bin/htsearch

More information about the MPlayer-users mailing list