Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # a simple script to watch tv with the ability to play/pause using mplayer
- # can be run as a script or put in /usr/bin and run as an application
- # if in /usr/bin be sure to chmod 755 what ever you name this so that it will be executable
- #
- # written by Jim Cook
- # azerthoth@gmail.com
- #
- # Script Version 2 added file rename, cleaned things up for those not using xdialog
- # broke mencoder command apart for easier reading and added deinterlacing
- #
- # first we flush to make sure we wont be catching the wrong resources
- killall mplayer > /dev/null 2>&1
- killall mencoder > /dev/null 2>&1
- # set the location to save the file to. This MUST be set even if you have no intention of keeping any of the programming you watch
- location=/mnt/tvstor
- # set filename
- filename=$(date +%H:%M:%S@%d-%h-%Y)
- # start mencoder
- # tv card on composite input and ntsc, mpeg format and mp3 audio
- # some of these settings may need to be changed to match your system or your personal preferences
- ((mencoder tv:// -tv driver=v4l2:input=1:norm=0:device=/dev/video0:adevice=/dev/dsp:forceaudio \
- -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200 -vf pp=ci,scale=640:480 \
- -oac mp3lame \
- -o $location/$filename.avi -v &) &)
- # give mencoder time to start before starting mplayer. too short a time will trigger the kill due to mplayer not finding a file to play
- sleep 5
- # start watching the TV show
- ((mplayer $location/$filename.avi &) &)
- # give mplayer a moment to start before watching for its pid
- sleep 1
- # watch for mplayer close and then close mencoder
- while [ "$(pidof mplayer)" ]
- do
- sleep 1
- done
- killall mencoder
- # pause to let mencoder shut down, not needed if using xdialog
- sleep 1
- # graphical save/rename or delete file.
- # change DIALOG=Xdialog to DIALOG=dialog if you want the box in the terminal session. Only if script is started via a terminal.
- # we put clear here to get rid of random text from terminal, not needed if running xdialog
- clear
- DIALOG=${DIALOG=Xdialog}
- $DIALOG --title "Save TV Show" --clear \
- --yesno "Do you wish to keep the file ?" 8 60
- case $? in
- 0)
- tempfile=`tempfile`
- $DIALOG --title "Rename Video File" --clear \
- --inputbox "Rename $filename.avi\n
- Adding .avi is not needed" 10 55 2> $tempfile
- retval=$?
- rename=`cat $tempfile`
- if [ -n "$rename" ];
- then rename=$rename
- else rename=$filename
- fi
- mv $location/$filename.avi $location/$rename.avi;;
- 1)
- rm $location/$filename.avi;;
- esac
- # clear terminal if no using xdialog
- clear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement