FB18 - Das Forum für Informatik

fb18.de / Off-Topic / Allgemeines

Linux + TV-Karte: Festplattenvideorecorderskript

Linux + TV-Karte: Festplattenvideorecorderskript 2005-01-08 02:16
Wolf
Dieses Skript nimmt innerhalb der nächsten 24h Sachen von der TV-Karte auf.
Copy&Paste in Datei "xawtv-recorder", ausführbar machen, testen, modifizieren…
#!/bin/bash # this script starts and ends recording via xawtv at given # times # Wolf wrote it, you may use and modify it. call it Public Domain # programs needed: xawtv, xawtv-remote, xine, aumix, date, bash, # killall startrecording () { ( # adjust audio levels for recording aumix -l R -l 80 -i 80 # kill all other instances of xawtv xawtv-remote quit >& /dev/null sleep 0,5 # we'll need a xawtv without xvideo extension # you won't be able to watch while recording! xawtv -noxv -geometry 480x360+0+0 >& /dev/null & sleep 1 # the settings for the file are applied # modify to reduce filesize xawtv-remote movie driver avi xawtv-remote movie video mjpeg xawtv-remote movie fps 30.0 xawtv-remote movie audio stereo xawtv-remote movie rate 44100 xawtv-remote movie fvideo $FILENAME xawtv-remote capture overlay sleep 0,5 # the recording begins xawtv-remote movie start sleep 0,5 checkend ); } endrecording () { ( sleep 0,5 xawtv-remote movie stop aumix -i 0 -v R sleep 0,5 xawtv-remote quit echo "Done!" ); } checkend () { ( echo "Recording... Ending time is $REC_END" if ( expr $REC_END == NOT_DEFINED >& /dev/null ); then ( echo "To end recording, press CTRL-C" ); fi while ( expr 1 = 1 >& /dev/null ); do ( NOW=$( date +%H.%M ) echo -ne $NOW"."$( date +%S )"\r" if ( expr $NOW == $REC_END >& /dev/null ); then ( echo -e "\nEnding record..." ; endrecording echo -e "Press any key for replay or press q to quit" read -s -n 1 CRABBLEDABBLE if ( expr a$CRABBLEDABBLE == aq >& /dev/null ); then ( echo "The written file is ~/$FILENAME" killall xawtv-recorder >& /dev/null ); fi echo "Playing $FILENAME ..." xine ~/$FILENAME >& /dev/null echo "The written file is ~/$FILENAME" killall xawtv-recorder >& /dev/null ); else ( sleep 15 ); fi ); done ); } countdown () { ( clear echo "Countdown is running. Target time: $REC_START" while ( expr 1 = 1 >& /dev/null ); do ( NOW=$( date +%H.%M ) echo -ne $NOW"."$( date +%S )"\r" if ( expr $NOW == $REC_START >& /dev/null ); then ( echo -e "\nStarting to record..." ; startrecording ); else ( sleep 15 ); fi ); done ); } # Here we go... echo "This is -------------------- xawtv-recorder ------------------------" echo -e "\nTip 1: Let the recording start 1 minute too early and end 1 minute late." echo -e "Tip 2: If you mistype something, press CTRL-W instead of BACKSPACE.\n" echo "Assure that your computer clock works correctly to get precise results." echo "To do that, just compare the output of date with an online date-/time-" echo -e "service.\n" echo "The given times have to be in hh.mm format. Otherwise, the program will" echo "never start / end recording. 01.35 is valid, 1:35 not." echo -e "Same goes for hour format: It has to be a number from 00 to 23. No am/pm.\n" echo "You may also type nothing and press ENTER to immediately start recording." echo -ne "\nStarting Time ( hh.mm ) : " read -n 5 REC_START if ( expr a$REC_START == a >& /dev/null ); then ( echo "The File is called: rip.avi. It is located in your ~/" echo "Don't forget to rename it to avoid accidental overwriting!" echo "To end the recording, just press CTRL-C. Don't panic, it'll work ;)" REC_START=$( date +%H.%M ) REC_END=NOT_DEFINED FILENAME=rip.avi countdown ); else ( IMMEDIATE=0 ); fi echo -ne "\nEnding Time ( hh.mm ) : " read -n 5 REC_END echo -e "\n\nThe File will be saved to your homedir." echo -ne "Filename ( automatic extension: .avi ) : " read FILENAME EXTENSION=.avi FILENAME=$FILENAME$EXTENSION countdown
Edit: Ist nicht aktuell.

Re: Linux + TV-Karte: Festplattenvideorecorderskript 2005-01-08 02:17
Wolf
Verbesserungsvorschläge sind erwünscht. Ich bin nämlich nicht der erfahrenste bash-Skripter [img]http://www.fb18.de/gfx/21.gif[/img]

Edit: Zwar ist es kein Thema, einen Kanalwechsel mit zu implementieren, aber bei meiner Kiste ist ein DVBT-Receiver dran, und der sendet nur auf einem Kanal. Nee, auf allen Kanälen den Kanal, den der Receiver ansagt.
Ergo muss ich am DVBT-Receiver noch jedesmal von Hand einen Timer einrichten, der auf den richtigen Kanal umschaltet.. So is das.

Edit2: Natürlich spielt bei der "Beschränktheit" des Skripts eine Rolle, dass die Postings auf Unimatix äh FB18.de eine Maximalgrösse haben.
Mittlerweile habe ich auch eine datumsabhängige Aufnahme "implementiert". Ich schätze aber mal, dass es niemanden interessiert und werde dieses Feature somit für mich behalten. [img]http://www.fb18.de/gfx/24.gif[/img]

Re: Linux + TV-Karte: Festplattenvideorecorderskript 2005-01-16 23:55
Wolf
Man kann das Aufgenommene mit z.B. xine zeitversetzt abspielen, auch während der Aufnahme; das nur pro forma.

Re: Linux + TV-Karte: Festplattenvideorecorderskript 2005-01-17 00:28
GroßerSchöpfer
Wie machst du die zweitversetzte aufnahme? Lässt du dein Skript selber warten? Ansonsten gibt es unter Unix dafür das nette Programmchen at.

Re: Linux + TV-Karte: Festplattenvideorecorderskript 2005-01-17 05:34
Wolf
Wie machst du die zweitversetzte aufnahme? Lässt du dein Skript selber warten? Ansonsten gibt es unter Unix dafür das nette Programmchen at.
Das mache ich mit date und if. Reicht aus :)
Nachteil ist natürlich, dass es sich um einen dicken fetten Vordergrundprozess mit eigener Shell handelt. Mit at oder cron-Kram wäre es eleganter.. Es ist ein Hack, ohne Frage, und kein besonders virtuoser [img]http://www.fb18.de/gfx/10.gif[/img]

Edit: Jetzt habe ich das Skript so schön mit Features vollgespickt und der Upload funzt nicht… Ein Posting wäre größer als die erlaubte maximale Postinggröße.. Wer also Interesse hat, melde sich bitte über Foren-SMS, bis der Upload wieder läuft.