Thursday, August 13, 2009

TV or video recording in ubuntu

Today my father persuaded me to start transcoding all his VHS collection to DVDs.

I thought to use his computer and his KWorld DVD Maker 2 Usb in Windows XP...in vain. KWorld does not complete the installation and I was stuck trying to figure out what was going wrong. So I decided to take it to my precious Ubuntu. Never having done an DVD2Xvid encoding, I was kinda curious what the results would be.

First of all, I
$ [sudo] apt-get install mercurial linux-headers-$(uname -r) build-essential udev

which would install mercurial and udev.
Then
$ hg clone http://linuxtv.org/hg/v4l-dvb
$ hg clone http://linuxtv.org/hg/dvb-apps
$ cd v4l-dvb
$ make
$ sudo make install


Everything went great so I continued with this command (I'm not sure if it's necessary):
sudo gedit /etc/modules

and added to the end of the file the following two lines:
#to record with kworld usb, I don;t need to say which one by saying >sudo em28xx card=12 or 10 etc.
em28xx


Reboot and then you will be able to check the video with this command:
mplayer -vf pp=lb -tv driver=v4l2:input=1:width=640:height=480:normid=5 tv://

If not, change input parameter to 0 or normid to whatever applies to your case(you will be able to check the available normids while mplayer is starting to play the stream).

Indeed by executing the
mencoder -tv driver=v4l2:width=576:height=480:device=/dev/video0:input=1:normid=5:forceaudio:immediatemode=0:adevice=/dev/dsp1 \-oac mp3lame -lameopts cbr:br=160 \-ovc xvid -xvidencopts fixed_quant=4:autoaspect=1 \-vf pp=lb -o input.avi tv://

I was able to start 1pass encoding (real time as the video was playing back) with the options mentioned before. In case you don;t have xvid
mencoder -tv driver=v4l2:width=720:height=576:device=/dev/video0:input=1:normid=5:forceaudio:immediatemode=0:adevice=/dev/dsp1 \-oac mp3lame -lameopts cbr:br=128 \-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2300:autoaspect=1 \-vf pp=lb -o input.avi tv://

seems to work as well and has similar results. Of course you can tweak as much as you want, if you know enough, the options in encoding.

The hard part is to find which is the video device and which the audio device. I didn't need to try a lot as there were not many video* in my /dev. Same goes for the microphone jack(/dev/dsp1).

Edit: I decided that the best way to convert the sound from VHS is to plug the in cable to the linein of my soundcard. Little did I know that it was a hassle of 6 hours... Anyway, I figured out that my soundcard was number 1 (number 0 is ATI's HDMI) so I ran this command

alsamixer -c 1

I then pressed to go to the capture view, pressed right to highlight LINE and then pressed space! See that's what's it's needed to tell alsa to CAPTUR from this input. If you want you can cancel (by presing space under the mic) microphone from capturing. Having done that, press escape and start your encoding.

By using linein, you can encode in stereo mode (whereas in mic you can't), or by using VHS sometimes there is a channel only at the right and only at the left. So by using -lameopts mode=3 we can tell mencoder to encode the audio stream in mono, while taking it as stereo! That way, it takes both channels and you don't have to care whether it is on the left or on the right.

mencoder -tv driver=v4l2:width=576:height=480:device=/dev/video0:input=1:normid=5:forceaudio:immediatemode=0:amode=1:adevice=/dev/dsp1 \-oac mp3lame -lameopts cbr:mode=3:br=80 \-ovc xvid -xvidencopts fixed_quant=4:autoaspect=1:threads=2 \-vf pp=lb -o input.avi tv://




Source:
  • http://linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers
  • No comments:

    Post a Comment