[wellylug] DSE & Linux

Ewen McNeill wellylug at ewen.mcneill.gen.nz
Tue Apr 20 23:26:46 NZST 2004


In message <4084FD26.5060403 at neko.net.nz>, Pizbit writes:
>Don't suppose you could share how you use mencoder to record and encode video
>from tv? I found a few examples using google not too long ago but none of them
>seemed to work for me.

What I'm using is:

-=- cut here -=-
#! /bin/sh
# Encode TV station with mencoder (using lavc)
CHANNEL=${1}
OUTPUT="${2-tv.avi}"
if [ -n "${CHANNEL}" ]; then
  v4lctl setstation "${CHANNEL}"
fi
exec /usr/local/bin/mencoder -idx -ofps 17 tv:// \
     -tv driver=v4l2:device=/dev/video0:width=720:height=576:fps=25:forceaudio=1
:audiorate=48000:amode=1:forcechan=2:adevice=/dev/dsp \
     -vf crop=704:576 \
     -oac lavc -ovc lavc -lavcopts vcodec=mjpeg:vqscale=6 -o ${OUTPUT}
-=- cut here -=-

which is "optimised" so that my Duron 700 can just keep up with real
time encoding (outputting 17 fps, at moderate quality, and with very
few filters).  It seems to be quite watchable, although I'm generating
in excess of 2GB of data per hour so it's not exactly well compressed.
(Not enough CPU time left to try to compress it better.)

The suggestion I found which I based this on was:

-=- cut here -=
# Based on suggestion from: 
# http://zebra.fh-weingarten.de/~maxi/html/mplayer-users/2003-08/msg00615.html
# 
/usr/local/bin/mencoder -idx -ofps 25 tv:// \
  -tv driver=v4l2:device=/dev/video0:width=720:height=576:fps=25:forceaudio=1:audiorate=48000:amode=1:forcechan=2:adevice=/dev/dsp \
  -vf crop=704:576,denoise3d=8:6:6,pp=md \
  -oac mp3lame -lameopts vbr=0:cbr:br=192:aq=0:mode=1 \
  -ovc lavc -lavcopts vcodec=mjpeg:vqscale=3
-=- cut here -=-

which didn't work for me (I didn't seem to have the right libraries for 
mp3lame to work).

I did get this minor variation working (using lavc for audio rather than
mp3lame):

-=- cut here -=-
/usr/local/bin/mencoder -idx -ofps 25 tv:// \
     -tv driver=v4l2:device=/dev/video0:width=720:height=576:fps=25:forceaudio=1:audiorate=48000:amode=1:forcechan=2:adevice=/dev/dsp \
     -vf crop=704:576,denoise3d=8:6:6,pp=md \
     -oac lavc -ovc lavc -lavcopts vcodec=mjpeg:vqscale=3 -o ${OUTPUT}
-=- cut here -=-

which produced really nice pictures, but unfortunately I could only do
about 12 fps on my Duron 700, so after about 30-60 seconds of recording
it was way too far behind and stopped recording due to lack of memory 
buffers.  (One day I'll get a faster machine.)  I figure that something
with about a 1.6 GHz or 1.8 GHz CPU would be able to keep up with all
of those things; anything over about 2.0 GHz should be easily fine even
while doing some other things.

This is all with a recent beta of mplayer/mencoding (1.0pre3 IIRC),
and a 2.4.25 kernel patched with the v4l2 patches and saa7134 driver
patch from bytesex.org.

FWIW, I've also found the "static" issue with changing channels from time
to time, but not yet issolated what causes it.  Changing channels a few
times does seem to reset it -- although I wouldn't say "rapidly changing".
I've not had any kernel crashes though.

Ewen




More information about the wellylug mailing list