LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 03-21-2007, 09:19 AM   #1
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 501

Rep: Reputation: 32
Mencoder for recording TV from a 878 tv card.


Hello!

First of all, let me tell you I am new to Ubuntu (I am trying this distribution now) and relatively new to Linux. As a computing teacher, I am trying to let my students know about Linux and its possibilities and advantages.

In order to show them (and myself too, of course :-) that Linux can be used as an alternative to win, I have to be able to do -at least- the same things I can do with Win. I know you understand.

So, let me tell you the problem I am facing now.

I can use TVTime to watch TV on Ubuntu 6.10. Now, I would like something really easy to record tv programs from my tv card (pinnacle pctv rave) and save them in DivX or Xvid format for later viewing. With sound, please.

I know Mencoder can do this but I get confused when reading lots of information about it with many parameters and don't really know how to reach my goal: To be able to record TV programs in DivX

I also know this is possible through the command line and using scripts. If so, let me also know where should I save them and how do I start those scripts.

So, if any of you could help me telling how to do this, I will really appreciate it.

I also know that Mythtv and Freevo are good programs but, for me, they are not too straightforward to install. I just want to be able to record a tv program from my tv card. That's it!

Thanks in advance friends,
G. Lorenzo.-
 
Old 03-21-2007, 11:04 AM   #2
Freemor
Member
 
Registered: Aug 2005
Location: New Brunswick
Distribution: Ubuntu 8.10 (Intrepid)
Posts: 70
Blog Entries: 8

Rep: Reputation: 15
Hello There,

The best place to put scripts you just want to use yourself is in the bin folder in your home directory. (you'll have to create it but if it exists ubuntu adds it to the $PATH)


here is the script I use to record TV with mencoder:

Quote:
#!/bin/bash
#
# script to encode tv using mencoder
#
# usage tape <channel#> <name> <duration>
#
CHAN="$1"
FNAME="$2"
DURATION="$3"

if [ $# -ne 3 ]
then
echo "Usage tape <Channel> <Name> <duration>"
echo "duration = hh:mm:ss"
exit
fi

echo
echo "Taping " "$FNAME""_`date +%m%d`"
echo

mencoder tv:// -tv driver=v4l:device=/dev/video0:width=352:height=240:fps=29.970:norm=ntsc:chanlist=us-cable:channel=$CHAN:saturation=-20:contrast=-20:audiorate=48000:immediatemode=0 -vf denoise3d -oac mp3lame -lameopts fast:
preset=medium -ovc lavc -lavcopts vcodec=mpeg4:vqscale=4:aspect=4/3 -endpos $DURATION -ffourcc DX50 -o "$FNAME"_`date +%m%d`.avi -quiet
everything after mencoder is one long line so if you cut and paste you may need to put that back together if LQ split it into multiple lines.

you'll need to change norm=ntsc,width=,height=,chanlist=,fps= if you are not in north america (most of europe would change this to norm=pal for example).
chanlist= - should be set to the correct one for your area

width=,height= - are set to preference as you can see I am not doing fullframe NTSC (that would be closer to 720x480) but my machine isnt currently fast enough to capture full frame as that requires deinterlacing.

fps= - varies by Standard also, but can be set to less then the full framerate if you choose. (NTSC=29.970, PAL=25, etc)


The -vf denoise3d is not strictly necessary I have some noise on some of my cable channels and that helps to clean it up.. but it can be dropped for slower machines.

Also the "saturation=,contrast=" are not strictly necessary I put them in as my tv card tends to "wash out" the video on some channels.

I usually run the "tape" script from a cron job. This will run it automatically and tape the programs I want.

for example the line:

00 17 * * 1-5 bin/tape 20 Voyager 01:00:00

tapes Voyager for me at 5 pm Mon-Friday. this is my user crontab not roots cron tab or the system cron scripts.. it's very easy to edit your local crontab using the "crontab -e" command in a terminal.

I also installed a "local mail only" postfix so that I get e-mail notifications of how my cronjobs did so I can see if there was a problem. (in /var/spool/mail/[username])

of course test the script from a terminal until you are sure it is working satisfactorally before you set it up as a cron job.

Hope this helps
Freemor

Last edited by Freemor; 03-21-2007 at 11:11 AM.
 
Old 03-21-2007, 11:25 AM   #3
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 501

Original Poster
Rep: Reputation: 32
Thank you!

Thank you for your answer. I will try this as soon as I get home from work.

If bin folder doesn't exist, I have to create it and...How do I add it to the path?

In order to start recording, I have to write mencoder name_of_the_script?

How should I call that script?

yes, I am new to this!!!

Thanks again.

G. Lorenzo.-
 
Old 03-21-2007, 12:11 PM   #4
Freemor
Member
 
Registered: Aug 2005
Location: New Brunswick
Distribution: Ubuntu 8.10 (Intrepid)
Posts: 70
Blog Entries: 8

Rep: Reputation: 15
Ubuntu should add the bin folder to the $path automatically .. you may have to log out and back in for it to pick up the changes and you might want to edit the default profile for the terminal window so it is run as a "login in shell" to do this:

Applications -> accessories -> terminal

on the terminal window:
edit -> profiles -> select "default" -> click edit on the side -> an options window pops up
click the "title and command" tab, about 2/3 of the way down there is a checkbox for "run as login" check it
then close -> close exit the terminal window and your done

for the script:

create the bin folder in your home directory, then appications, accessories,text editor
copy and paste the script into the text editor, fix as necessary, save it to the your bin folder as "tape"

click places -> home folder -> go into you bin folder -> right click "tape"
choose Properties, click the permissions tab, check the executable option on the user row
click close. close or minimize nautilus, open a new terminal window.

you should now be able to type: tape <channel> <name> <duration> at the command line to start taping
(of course replace <channel>, etc with the appropriate values. eg. "tape 5 foo 00:01:00"
would make a 1 minute test recording from channel 5 and call it foo_mmdd.avi where mmdd the month and day.
I added appending MMDD to the file name so when taping from a cronjob i don't get file collisions
when I tape the same program the next day.

if you get video but no sound make sure that the proper capture line is set (right click on the
speaker next to the clock and chose "open volume controls". then on the capture tab it's usuallt the "line-in" that you want to capture but this may vary depending on your computer/TV card.)

If it bitches about not being able to encode to mp3 you may need to make sure "lame" is installed (sudo apt-get install lame)

if it is failing and you aren't sure why edit the tape script and remove the -quiet option this will make the output much more verbose. (you'll probably want to put the "-quiet" back in before using it as a cron job if you plan to get the e-mails)

Hope this helps
Freemor
 
Old 03-21-2007, 04:49 PM   #5
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 501

Original Poster
Rep: Reputation: 32
Freemor: You are the Master of the Universe!!!

Thanks Freemor for you valuable help and the very detailed explanation!!! Now I can record TV programs with Mencoder!!.
At the beginning I didn't get any sound on the recorded file. But if I change the Sound Device to Sigmatel (OSS Mixer) instead of Via 82c686A/B (ALSA Mixer), it works. I feel really happy now! (it sounds crazy for a 43 year old teacher but I am happy :-)

Is there any way to use the VIA Device (alsa) instead of the Sigmatel? I've tried to change the capture settings but no sound (There is sound while recording but no when playing it back).

Can you also tell me how do I build that cron job (that would be great too!)

If I try to watch TV while recording, the images go slow. Is there a way to avoid this too? My computer is an old Athlon XP 1800 with 768Mb RAM and a GeForce FX 5500 128Mb.

Do you use Mencoder to record your TV programs or MythTV / Freevo? I've tried to install both of them. I've got further with Freevo but when it starts, I have nothing configured. So, if you know how to do that too,

Your script is great. Let me paste you a copy of how mine is (with Pal-nc standard). Maybe it is useful for someone else with the same parameters.

And again: Thank you very much!!!

My mail is glorenzo@hotmail.com. If you want to send me yours, I will really appreciate it.

Well, here it goes the script (just the part corresponding to mencoder):

mencoder tv:// -tv driver=v4l:device=/dev/video0:width=320:height=288:fps=25:norm=palnc:chanlist=us-cable:channel=$CHAN:saturation=-20:contrast=-20:audiorate=48000:immediatemode=0 -vf denoise3d -oac mp3lame -lameopts fastreset=medium -ovc lavc -lavcopts vcodec=mpeg4:vqscale=4:aspect=4/3 -endpos $DURATION -ffourcc DX50 -o "$FNAME"_`date +%m%d`.avi -quiet

Last edited by glore2002; 03-21-2007 at 05:05 PM.
 
Old 03-21-2007, 05:50 PM   #6
Freemor
Member
 
Registered: Aug 2005
Location: New Brunswick
Distribution: Ubuntu 8.10 (Intrepid)
Posts: 70
Blog Entries: 8

Rep: Reputation: 15
Try changing the driver=v4l to driver=v4l2 that might fix up the alsa.

the cron job is easy in a terminal just type crontab -e (-e for edit)
you'll probably want to add a "reminder" line at the top like:

Quote:
# m h dom mon dow command
to remind you what the fields are then a line like:

Quote:
# Tape Heroes
00 21 * * 1 bin/tape 17 Mobile/Heroes 01:10:00
the fields are:

m = minutes
h = hours
dom = day/s of the month
mon = month/s
dow = day/s of the week
command = the command to run

there is a good intro to cron here:

http://www.tech-geeks.org/contrib/md...ron-howto.html

I use my tape script from a cron job all the time it is lightest on the system and gives me
full control over the recording settings. I looked at Freevo and MythTV but I'd only use those
on a dedicated box.

as for watching while playing.. you'd need a lot of horsepower for that
(like AMD X2 processor or something) or to use a less proccessor intense
codec but then you'll be looking ay 2+ Gigs for a file and need to post
encode it to divx aftrwards.. so I just wait and watch after.

Glad it helped
Freemor
 
Old 03-21-2007, 06:31 PM   #7
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 501

Original Poster
Rep: Reputation: 32
Just...Great!!!

Thank you!!!! I will try those changes to the script.

Yes, you really helped me!

Thanks again Freemor.
G. Lorenzo.-
 
Old 03-21-2007, 07:27 PM   #8
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 501

Original Poster
Rep: Reputation: 32
Something else...

Freemor, I changed v4l to 4vl2 and this is what happened:

The sound was recorded OK but the image was B/W. Then, I turned it back to v4l and... everything worked OK (with sound included). So, I don't understand what changed but it is working now so everything is ok :-)

By the way, What should I add to crontab to tell Ubuntu to shutdown the computer after recording? Is that possible?

Thanks again,
G. Lorenzo.-
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording Video and Audio using mencoder OR13 Linux - Desktop 3 01-19-2007 04:19 PM
Mythtv, Bttv, Pinnacle 878, tv-card, faild to open the card THOR_Fedora Linux - Software 2 12-11-2006 11:59 AM
ati tv wonder mencoder recording vhs tape pld Linux - General 2 04-19-2005 08:57 PM
SuSE 9.2 (64 bit) + Hauppauge 878 <> working TV rcaban Linux - Hardware 0 02-11-2005 04:12 PM
Need help recording to hd from tv card Lakota Mandriva 0 10-25-2003 04:52 PM


All times are GMT -5. The time now is 05:42 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration