Webmaster Key - Discussion Forums


Welcome, Guest. Please login or register.
Did you miss your activation email?
February 07, 2012, 10:21:15 AM

Login with username, password and session length
Welceome to Forums!

Important information for guests and new members:

In order to understand the full benefits of becoming an active member of this forum, please review the following information on guest and new member restrictions. These forum changes have been prompted by an overwhelming and unreasonable amount of bot postings and incoherent guest spam messages. We wish to prevent these events from happening in the future and make our community a more comfortable place for all of our members.

For guests:

Guests are not allowed to open new topics, polls, or posts attachments.
If you wish to open up new discussions on this forum, we encourage you to register.

For new members:

New members with less than five posts are not allowed to modify additional profile information such as avatars, contact information, biographies, and signatures. However, new members are encouraged to post their own topics or reply to topics initiated by other members. Become active on the forums and 5 posts should be an easy task!

We are a diverse community with members from all over the world. We encourage new ideas and interesting conversation. Do not be afraid to post webmaster/computer-related questions or problems, as our active members are always willing to help when they are able. Interested? Join us.

+ Webmaster Key Forums
|-+ General Discussion
| |-+ Tech Corner
| | |-+ HOWTOs Library
| | | |-+ [Linux] HOWTO rip video from TV Tuner by time/date with mencoder(part of MPlayer
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print
Author Topic: [Linux] HOWTO rip video from TV Tuner by time/date with mencoder(part of MPlayer  (Read 3056 times)
SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« on: November 20, 2005, 10:27:06 PM »

more than one year ago I've completely switched to Linux and some time later I've got myself TV tuner AverTV Studio 305 and I've tried it with several programs i.e. xawtv, zapping, tvime and stop my choice on tvtime which gives best picture quality. Unfortunately tvtime can't record video, first I was using streamer it let you record directly from tvtuner and encode video into MJPEG but it was producing pretty big files and also doesn't give you possibility to switch channels so I had to do this manually through tvtime. So after all I've start to dig info on how to switch channels and find out that it could be done through MPlayer or mencoder(which is a part of MPlayer package used for encoding and recording video).
Here  is the small script I've wrote which would let you make schedule with cron and record your favourite programs in according to schedule from various TV channels.
Here is the script:
Code:
#!/bin/sh

#Set path were video files should be stored
rec_path='/opt/vcr'

#Set size of the picture taken from V4L2
width=640
height=480

#Set Birtate. for 640*480 movie I'm using 900kbps, but if you play with width and height options you may try to lower this number
bitrate=900

#Setting input driver it should either be v4l or v4l2
driver='v4l2'
#driver='v4l'

#Getting current date and time. It would be used to generate filename
DATE=`date +%d_%b-%H:%M`

#stopping tvtime and if it's running
killall tvtime

#Tuning frequency corresponding to given chanel
case "$1" in
discovery|1)
#Setting channel name
name="Discovery"
#Setting it's frequency in MHz
freq="49.76"
        ;;

hallmark|2)
name="HallMark"
freq="85.20"
        ;;

rambler|3)
name="Rambler"
freq="271.25"
        ;;

*)      echo "Start recording like this: tvrec 1 60:00 MythBusters"
        exit 1
        ;;
esac

echo $name "channel selected"
#Creating directory for given channel if it not exist
mkdir $rec_path/$name
chmod 777 $rec_path/$name
#Starting up mencoder
mencoder tv:// -tv device=/dev/video0:driver=$driver:width=$width:height=$height:freq=$freq:norm=PAL-DK -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$bitrate -oac lavc -ffourcc DX50 -vf pp=lb -endpos $2 -o $rec_path/$name/$3-${DATE}.avi

1. In order to make this script working you'll need to have mencoder package(if you have MPlayer package installed you probably already have mencoder installed as well. If not it's time to obtain packages for distribution you're using or compile it from the source.

2. install this script in /bin folder and name it tvrec

3. change owner of the script so it could be executed by non-root users, it could be done like this:
Code:
chown denis /bin/tvrec

make sure that it has necessary permissions like this to be executed:
Code:
chmod 754 /bin/tvrec
this would make possible to run this script by owner and group.

4. edit this line rec_path='/home/denis/video' in the script to the folder where you'd like video files to be stored.
if you watch films in a small window(as I usually do) or wish to save on the diskspace, you can try to play with width and height and bitrate options.

5. now you need to make your channel list (I not very advanced yet in BASH scripting and also very lazy to write script which takes frequencies from tvtime config, so as for now you have to do it manually, if someone would contribute such script I'd appreciate his/her help), you'll need to know frequencies of the channels you're going to record from. If you're using TVTime you can easily obtain them like this cat /home/denis/.tvtime/stationlist.xml

if all previous steps was done you should be ready to make testing recording:
just try to execute some command like:
Code:
tvrec 1 00:05 testing
it should create directory according to channel name(in my case it's Discovery) under /home/denis/video and create there 5 seconds of recording with name combined form current time and word "testing".
If file was successfully created than you can proceed with installing cron job.

NOTE: If you've installed mplayer from the source it's good idea to create symlink to the mencoder like this:
Code:
cd /bin
ln -s /usr/local/bin/mencoder .
I've run in the same problem myself as script work perfectly when I start it from console but cron won't run it... it's happend because cron doesn't see same environment variables as users. You can avoid this problem by setting PATH variable in this script itself. So if you don't wish to create symlink simply make this:
Code:
which mencoder
this command would return path to mencoder, something like this "/usr/local/bin/mencoder". once you find out directory where it's stored simply add this line:
PATH=/usr/local/bin;
somewhere in the beginning of tvrec script.

6. now you can setup some cron job like this,
Code:
crontab -e -u denis
in crontab put line like this:
00 20 * * Mon,Tue,Wed,Thu,Fri tvrec 1 60:00 myhtbusters
this would record Myth Busters program from Monday to Friday.

Hope this small script would be useful for you so as for me. Let me know if you have any troubles with using it and I'll try to help. I also would be glad to hear and feedback or maybe suggestions on improvements.

* tvrec.txt (1.69 KB - downloaded 117 times.)
« Last Edit: October 17, 2006, 03:13:39 PM by SensoVision » Report to moderator   Logged

Denis
SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #1 on: December 27, 2005, 09:55:25 PM »

just wonder if anybody tried/using this script except myself?
BTW for period I'm using this script, it save me a lot of time, I no longer try to catch my favourite programs, I simply do my day job and know that when I had spare time I can watch recorded program.
Report to moderator   Logged

Denis
Pages: [1] Go Up Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print 
+ Webmaster Key Forums
|-+ General Discussion
| |-+ Tech Corner
| | |-+ HOWTOs Library
| | | |-+ [Linux] HOWTO rip video from TV Tuner by time/date with mencoder(part of MPlayer

Jump to:  
« previous next »


Our Partners
RelmaxTOP Ranking System Web Hosting RelmaxTOP Ranking System
Staff Sites
12Noon[12Noon Gallery] Andy[Urgentclick]
Tamuril[Tamuril's Digital Art Exhibit] Sensovision
Powered by MySQL Powered by PHP We are hosted by Relmax Inc. |Our Privacy Policy | Sitemap
Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Forum design by Tamuril © 2005.
Valid XHTML 1.0! Valid CSS!