hoerdt.org hoerdt.org
  [Back] [Forward] [Home] [Escape frames] [Email this page] [Search with Google] [Add to IE favorites] [Print preview]

Linux TV & [S]VCD Mini-Mini-HowTo

TV-Aufnahme

Folgende Kommandozeile nimmt 25 Sekunden ZDF mit 2500 KBit/s Video und 128 KBit Audio als MPEG4 auf und schneidet noch ein paar Pixel vom Rand (Austastlücke usw.) ab:

mencoder -tv \ driver=v4l:width=768:height=576:adevice=/dev/dsp1:channel=E6:\ chanlist=europe-west:forcechan=2:amode=2 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -oac mp3lame -lameopts \ cbr:br=128 -srate 48000 -o <output_file> -endpos 25 vf \ -crop=760:570:4:3,pp=lb tv://

Oder das Ganze DVD-ähnlicher als MPEG2:

mencoder -tv \ driver=v4l:width=768:height=576:adevice=/dev/dsp1:channel=E6:\ chanlist=europe-west:forcechan=2:amode=2 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -oac mp3lame -lameopts \ cbr:br=128 -srate 48000 -o <output_file> -endpos 25 vf \ -crop=760:570:4:3,pp=lb tv://

Hinweis: Beim hier verwendeten Tuner (Phillips PAL_BG, bttv tuner=5) musste per forcechan=2 und amode=2 dafür gesorgt werden, dass auch wirklich in stereo aufgenommen wurde (obwohl amode=2 gemäß man mencoder "language 1" ist).

Sollte mencoder immer noch ein paar Frames beim Encoden verlieren, kann ich eine Anpassung der Priorität (schedule, nice-Level) des Prozesses vie schedtool empfehlen. Weiterhin kann die erforderliche Bitrate durch ein vorgeschalteten denoise-Filter (z.B. mencoder-Option -vf denois3d) erheblich reduziert werden - was jedoch wieder intensivere CPU-Nutzung bedeutet.

Nach vielen Versuchen sehen meine Kommandos zum Aufnehmen (muss wegen schedtool u.a. als root oder via super/sudo ausgeführt werden) nun so aus, was bei meinem Rechner (AMD Athlon XP 2600+) für mich recht akzeptable Werte (Ziel: SVCD) liefert:

# modifying latency timers: # bttv: /opt/super/lbin/setpci -v -s 00:13.0 latency_timer=f8 # VGA: /opt/super/lbin/setpci -v -s 00:10.0 latency_timer=20 # stopping ntp: /opt/super/lbin/ntpd stop # Sleeping a while: sleep 10 # recording with mencoder: /opt/super/lbin/sschedtool -R -p 99 -n -19 \ -e mencoder -tv \ driver=v4l:width=480:height=576:adevice=/dev/dsp1:channel=$CHANNEL:chanlist=eur -ovc lavc -oac lavc \ -lavcopts vcodec=mpeg2video:vbitrate=5000:turbo:acodec=mp2:abitrate=128:aspect= -vf hqdn3d,pp=lb,harddup -srate 48000 \ -o $FILENAME -endpos $DURATION tv:// \ >> /dev/null \ 2>> $FILENAME.log # re-setting latency timers: # bttv: /opt/super/lbin/setpci -v -s 00:13.0 latency_timer=20 # VGA: /opt/super/lbin/setpci -v -s 00:10.0 latency_timer=f8 # starting ntp: /opt/super/lbin/ntpd start

Links zum Thema:

Konvertierung

Aus allem, was MPLayer abspielt, kann man mittels encode2mpeg [S]VCD-kompatible MPEG1-Dateien generieren.

Beispiel für VCD:

encode2mpeg <input_file> -quiet -vcd -a 2 -mpegfixaspect -normalize \ -mpegonly -vfr 3 -n p -o <output_file>

Beispiel für SVCD (mit Splitting):

encode2mpeg <input_file> -a 2 -mpegfixaspect -quiet -svcd \ -normalize -split 790 -vfr 3 -n p -mpegonly -o <output_file>

Ggf. ist vorher das Video auf 25 fps zu bringen, was sehr komfortabel mit mencoder funktioniert:

mencoder -ofps 25 -oac pcm -ovc raw <input_file> -o \ <output_file>

Die Codierung mittels encode2mpeg gibt hin und wieder einen Versatz zwischen Bild und Ton, welcher jedoch mit der Option -sync-offset korrigiert werden kann.

Verzögerungen zwischen Audio und Video lassen sich auch sehr komfortabel mittels Avidemux bzw. dessen Audio- & Video-Filtern beheben, jedoch entsteht dabei oft eine MPEG-Datei, die nicht mehr dem VCD-Standard genügt und daher nochmals durch encode2mpeg gejagt werden muss.

Die Konvertierung kann auch mittels transcode erfolgen, wie z.B. hier als Konvertierung in eine SVCD-konforme MPEG-Datei:

transcode -x ffmpeg,mp3 -i <input_file> -y mpeg2enc,mp2enc -E 44100 \ --pre_clip 6,8,6,8 -F '4, -S 792' -w 230 -b 128 -Z 480x576 -j 0 -z -k \ -J normalize,dnr -o <output_file> -c <startpos>-<endpos>

Einen guten Vergleich zwischen den verschiedenen Deinterlace-Optionen für transcode findet man unter tibit.org - Linux Video Hacks.

Links zum Thema:

X & TV-Out

XF86Config für Nvidia im Xinerama-Modus - rechter Screen wird über TV-Out ausgegeben:

# XFree86 4 configuration created by pyxf86config Section "ServerLayout" Identifier "Default Layout" Screen 0 "Screen0" 0 0 Screen 1 "Screen1" RightOf "Screen0" InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" InputDevice "DevInputMice" "AlwaysCore" Option "Xinerama" "on" EndSection Section "Files" # RgbPath is the location of the RGB database. Note, this is the name of the # file minus the extension (like ".txt" or ".db"). There is normally # no need to change the default. # Multiple FontPath entries are allowed (they are concatenated together) # By default, Red Hat 6.0 and later now use a font server independent of # the X server to render fonts. RgbPath "/usr/X11R6/lib/X11/rgb" FontPath "unix/:7100" EndSection Section "Module" Load "dbe" Load "extmod" Load "fbdevhw" Load "glx" Load "record" Load "freetype" Load "type1" # Removed for nvidia driver: # Load "dri" EndSection Section "InputDevice" # Specify which keyboard LEDs can be user-controlled (eg, with xset(1)) # Option "Xleds" "1 2 3" # To disable the XKEYBOARD extension, uncomment XkbDisable. # Option "XkbDisable" # To customise the XKB settings to suit your keyboard, modify the # lines below (which are the defaults). For example, for a non-U.S. # keyboard, you will probably want to use: # Option "XkbModel" "pc102" # If you have a US Microsoft Natural keyboard, you can use: # Option "XkbModel" "microsoft" # # Then to change the language, change the Layout setting. # For example, a german layout can be obtained with: # Option "XkbLayout" "de" # or: # Option "XkbLayout" "de" # Option "XkbVariant" "nodeadkeys" # # If you'd like to switch the positions of your capslock and # control keys, use: # Option "XkbOptions" "ctrl:swapcaps" # Or if you just want both to be control, use: # Option "XkbOptions" "ctrl:nocaps" # Identifier "Keyboard0" Driver "keyboard" Option "XkbRules" "xfree86" Option "XkbModel" "pc105" Option "XkbLayout" "de" Option "XkbVariant" "nodeadkeys" EndSection Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/psaux" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection Section "InputDevice" # If the normal CorePointer mouse is not a USB mouse then # this input device can be used in AlwaysCore mode to let you # also use USB mice at the same time. Identifier "DevInputMice" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "BenQ T904" DisplaySize 380 300 HorizSync 31.0 - 83.0 VertRefresh 56.0 - 76.0 Option "dpms" EndSection Section "Monitor" Identifier "Monitor1" VendorName "Monitor Vendor" ModelName "TV" DisplaySize 380 300 HorizSync 30-50 VertRefresh 60 EndSection Section "Device" Identifier "Videocard0" Driver "nvidia" VendorName "Videocard vendor" BoardName "Nvidia" Option "ConnectedMonitor" "CRT" BusID "PCI:1:0:0" Screen 0 EndSection Section "Device" Identifier "Videocard1" Driver "nvidia" VendorName "Videocard vendor" BoardName "Nvidia" Option "ConnectedMonitor" "TV" BusID "PCI:1:0:0" Option "TVOverScan" "1.0" Screen 1 EndSection Section "Screen" Identifier "Screen0" Device "Videocard0" Monitor "Monitor0" DefaultDepth 16 SubSection "Display" Depth 16 Modes "640x480" EndSubSection EndSection Section "Screen" Identifier "Screen1" Device "Videocard1" Monitor "Monitor1" DefaultDepth 16 SubSection "Display" Depth 16 Modes "640x480" EndSubSection EndSection Section "DRI" Group 0 Mode 0666 EndSection

Der dazu passende Aufruf von Xine (controls auf linkem Screen, Ausgabe auf rechtem Screen und damit über TV-Out):

xine -V Xv -B -G 640x480+640+0

Links zum Thema:

comfycombo.com