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
- #
- # first we flush to make sure we wont be catching the wrong resources
- killall mplayer
- killall mencoder
- # 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:width=640:height=480:device=/dev/video0:adevice=/dev/dsp:forceaudio -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200 -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 2
- # watch for mplayer close and then close mencoder
- while [ "$(pidof mplayer)" ]
- do
- sleep 1
- done
- killall mencoder
- # graphical delete or save file using dialog/xdialog
- # change DIALOG=Xdialog to DIALOG=dialog if you want the box in the terminal session. Only if script it started via a terminal.
- DIALOG=${DIALOG=Xdialog}
- $DIALOG --title "Save TV Show" --clear \
- --yesno "Do you wish to keep the file ?" 8 60
- case $? in
- 0)
- clear ;;
- 1)
- rm $location/$filename.avi ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement