View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue Sep 06, 2005 1:05 pm 
Hi,

I have been converting some home videos on the hand recorder and VCR to MythTV videos and this is how I have been doing it:

Go to the default TV tuner recording profile and crank resolutions and bitrates, quality factors to their maximums (720x480 at 16000 kbps). This will create high quality videos with enormous file sizes.

Switch to console (ctrl-alt-F1), login as root, and change directories to /myth/video

turn on video source (VCR, hand camera, etc) put in tape and rewind to the beginning, and plug audio and video lines in.

at console, switch recording input to composite 0 (I have PVR-250, this will vary by type) type in:

#ivtvctl -p 5
#cat /dev/video0 >home_video_01.mpg

let the tape play until the part you want has played and press ctrl-c to end the recording.

Now you'll have a huge video file (some of mine are over 11 GB long)

that may be enough if all you want is to store it on your MythTV PVR but if you want a more reasonable file size and/or to export it you need to transcode the file to some thing that preserves quality but reduces file size.

I have a neat little script to do that very thing using software on your knoppmyth box called mpg2avi (the name is probably already taken but since its limited to my box it is no problem -- call it whatever you like):

Quote:
mencoder -ovc xvid -xvidencopts pass=1 -nosound -o $1.avi $1
mencoder -ovc xvid -xvidencopts bitrate=2200:pass=2 -oac mp3lame -lameopts preset=medium -o $1.avi $1


open a file using an editor and cut'n paste the above into it and set protections with

#vi /myth/video/mpg2avi
i [paste in above]
:wq

#chmod 755 mpg2avi

then start the transcode with

#./mpg2avi home_video_01.mpg

hours later you'll get a file called home_video_01.mpg.avi

Use the video manager to import the file into MythTV. Delete the original recording if you care about disk space or keep it as an archive copy.

I like to do this because it gets all the tapes laying about into the PVR so the kids and family can watch them whenever they want.

Thoughts, critiques? Thanks!

Andrew Lynch


Top
  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 1:10 pm 
BTW, the transcoding step can be easily be done on a Windows PC as well. Just transfer the large original recording via SAMBA share (search the knoppmythwiki for instructions), get Mplayer (google on Mplayer) and with a couple of tweaks to the script it works just fine.

If anyone wants, I'll post the windows script file as well.

BTW, the script works on MPEG2 file or any file that MPlayer/Mencoder can play. So if you have perfect rips (ie, .vob files) of those DVDs in your /myth/video directory hogging up space, transcode them to HQ Xivd and save some space!

Thanks!

Andrew Lynch


Top
  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 8:49 pm 
Here is an improved version of the script that converts all the files you pass to it as a wildcard.

The script does not deal well with perfect DVD rips though if the file names have spaces in them. Anyone want to improve the script to handle filenames with spaces?

Thanks!

Quote:
#cat /usr/local/bin/mpg2avi



for file in "$@"
do
mencoder -ovc xvid -xvidencopts pass=1 -nosound -o $file.avi $file
mencoder -ovc xvid -xvidencopts bitrate=2200:pass=2 -oac mp3lame -lameopts preset=medium -o $file.avi $file
done



Thanks!

Andrew Lynch


Top
  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 5:50 am 
Offline
Joined: Fri Apr 02, 2004 10:08 am
Posts: 1637
Location: Virginia, USA
Andrew: I would argue (politely :) ) that the quality limit is the source material, namely, VHS.

Recording an MPEG2 file at 16Mbps is overkill for VHS source material. I would bet that one would not be able to tell a difference between that file and a recording made at (say) 8Mbps... quite frankly that's probably overkill too. The advantage of the 8Mbps file is that it is under the limit for DVD authoring, so you could author a DVD with that file and any DVD player could play it.

Similarly, I would bet that one would not be able to tell a difference between a XviD transcode made from the 16Mbps MPEG2 vs the 8Mbps MPEG2.

If I were you I would experiment with different combinations of bitrate (8Mbps, 6Mbps, 4Mbps) and resolutions (720x480, 352x480) and find the "sweet spot" that preserves whatever video quality you have in the VHS original, yet minimizes file size.

If I were doing it I'd probably opt for storage over quality and go 4Mbps at 352x480. But that's just me.

OK, criticism over: thanks very much for the post. I really need to dub a lot of VHS and get them thrown out, and this gives me some incentive to try to do so. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 1:15 pm 
You are probably right on the data rates especially if you are going to keep the MPEG2 files. As for VHS video quality -- it blows -- no argument there.

I keep the rates very high on the default recording profile because I have noticed major differences in transcode quality when recording shows from analog cable. ( and I am also too lazy to change the rate between recordings...) Even a little bit of noise on a mid to low data rate recording turns into a horrid transcode picture quality.

It is probably overkill but since the MPEG2 is essentially a temporary file its no big thing. Its the XviD MPEG4 that I keep and it is about 1 GB per hour of video.

The home videos give my wife and kids hours of enjoyment. Those and "Dancing with the Stars". They love them and as long as they are happy it helps with WAF so I am happy.

Andrew Lynch


Top
  
 
 Post subject:
PostPosted: Sun Sep 11, 2005 2:35 pm 
Hi,

One problem I have had transcoding imported DVD title is that filenames contain spaces. After a bit of experimenting and googling, I found a shell script that converts filenames with spaces to filenames with underscores.

You probably want to use this with some caution but it sure is handy for converting a directory full of vob files with funky filenames.


#cat /usr/local/bin/underscore


find . -iname '* *' |
while read f ; do
mv "$f" "`echo "$f" | sed 's/ */_/g'`"
done


Andrew Lynch


Top
  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 4:23 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
Very nice method! Thanks for typing all the details by the way. The video quality is great for me with just standard res/bitrates (640x480, 4000-6000 vbr vid).

I do have a problem though: what do I need to do in order for audio to work? I have the video going to my PVR-250 as you instructed, and the audio is going to my MB's Line In jack via a Y-cable that I know to be good. Currently, both left and right audio tracks are just flat lines, although audio data is getting written into the mpeg file.

Mythtv works fine with audio/video out-of-the-box (R5A15.1).

My hardware:
Asus A7N8X-VM board, details from manual:
-NVIDIA nForce2 chipset
-onboard audio: Realtek ALC850 6-channel CODEC
-onboard LAN: Realtek BL PNY 10/100 Mbps
Athlon 1900+
2x256 Meg PC2100
320 gig Seagate
PVR-250
GF4 440MX w/ 64 meg

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 5:40 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
Update:

Starting playing around with the ivtvctl help and did:

Code:
$ ivtvctl --help | grep audio
  -A, --list-audio-inputs
                     display audio inputs [VIDIOC_ENUMAUDIO]
  -Q, --get-audio-input
                     query the current audio input [VIDIOC_G_AUDIO]
  -q, --set-audio-input=<num>
                     set the current audio input to <num> [VIDIOC_S_AUDIO]
       volume        =<#> Overall audio volume. [0 - 65535]
       mute          =<#> Mute audio, i.e. set the volume to zero [boolean]
       audio         =<#> sets audio bitmask (try 0xE9)

You'll get some options. Then I did a:

Code:
$ ivtvctl -A
ioctl: VIDIOC_ENUMAUDIO
        Input   : 0

        Name    : Tuner Audio In

        Input   : 1
        Name    : Audio Line In


Okay, so there is a Line in. So I selected it using:
Code:
$ ivtvctl -q 1 -p 5
ioctl: VIDIOC_S_INPUT
Input set to 5
ioctl: VIDIOC_S_AUDIO
Input set to 1


Finally, I tried to capture audio and video using:
Code:
$ cat /dev/video0 > test.mpg


Again, I got a video stream with no audio :( I will say that if I switch the audio back to the turner's source and repeat the capture, I get my video with the audio track for whatever channel the tunner is set to... does this mean my cables are bad or my linein jack is bad?

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 6:02 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
UPDATE 2:

mjl solved my problem for me in this thread and it didn't require any special switchs for ivtvctl at all. Turns out I needed to use my PVR250's line in, not the one in my PC. Made that little switch and now I can capture audio and video with no problems.

Thanks Mike!

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Last edited by graysky on Sat Oct 08, 2005 6:15 am, edited 1 time in total.


Top
 Profile  
 
PostPosted: Sat Oct 08, 2005 6:07 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
lynchaj wrote:
Go to the default TV tuner recording profile and crank resolutions and bitrates, quality factors to their maximums (720x480 at 16000 kbps). This will create high quality videos with enormous file.

...

at console, switch recording input to composite 0 (I have PVR-250, this will vary by type) type in:

#ivtvctl -p 5
#cat /dev/video0 >home_video_01.mpg


Is there a way one can specify an alternative recording profile using this method? I.e. my mythtv high quality instead of default quality?

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 9:38 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
lynchaj wrote:
If anyone wants, I'll post the windows script file as well.


Please do, but if you don't mind, I started a new thread in the off topic area for this; please post here.

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:54 pm 
Offline
Joined: Tue May 17, 2005 6:48 pm
Posts: 9
I have a Happauge PVR-250 capture card with a Knoppmyth install. I am trying to capture some VHS recordings and transcode them into something smaller.
I use the command:

#ivtvctl --set-input=5

to successfully set my PVR250 to the composite input,
then I change to an appropriate directory with some room (.ie /myth),
hit play on the VCR and then start capturing with:

#cat /dev/video0 > filein.mpg

Then to transcode, I use my own version of the script in this thread (see link below) using the command:

#mpeg2avi filein.mpg fileout.avi 320 240 180 2 1188

This will transcode the file: filein.mpg into the avi file: fileout.avi
Using 320X240 resolution with a target size of 180 MB.
Beginning at time=2 seconds, ending at time 1188 seconds.

Rather than specifying the bitrate, my script allows the user to enter the target filesize and then the program will calculate the bitrate needed. Also, I added parameters so the start time and end time can be given. The problem I am currently having with it involves the audio. It will not start at any time other than zero even when mencoder is given the -ss parameter. So the audio in the above example is shifted by 2 seconds, but if I start at time=zero, it works well.

For video coding, the -ss parameter seems to work fine. So I suspect if I could use another utility to trim off the beginning of the .mpa sound file created during the audio transcoding, I could get this thing to work for non-zero starting times. I think this would be most useful as it is fairly easy to capture a six hour tape in one big mpeg2 file, then use this script to transcode that to smaller avi files.

Does anyone know what command line utility can be used to trim the beginning of audio? Which audio format should I be using?

Click for MPEG2AVI script

If the above link doesn't work or you just want the nuts and bolts of what's going on... Here's the three relevent commands in the script:

** first get audio **
# mencoder $filein -ovc frameno -oac mp3lame -lameopts vbr=3 -o frameno.avi -ss $begsec -endpos $endsec

** first video pass **
# mencoder $filein -oac copy -vf pp=md,scale=$sizex:$sizey -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=$bitrate:vqscale=3:vhq:v4mv:trell -o /dev/null -sws 2 -ss $begsec -endpos $endsec

** second video pass **
# mencoder $filein -oac copy -vf pp=md,scale=$sizex:$sizey -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=$bitrate:vqscale=3:vhq:v4mv:trell -o $fileout -sws 2 -ss $begsec -endpos $endsec


Top
 Profile  
 
PostPosted: Sun Jun 22, 2008 10:03 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
lynchaj wrote:
at console, switch recording input to composite 0 (I have PVR-250, this will vary by type) type in:

#ivtvctl -p 5
#cat /dev/video0 >home_video_01.mpg

let the tape play until the part you want has played and press ctrl-c to end the recording.

Now you'll have a huge video file (some of mine are over 11 GB long)


It's been a while, but I find myself needing to do it w/ my R5F27 box which uses ivtvctl version 0.10.5 which doesn't support the -p 5 switch. I looked at the help output but it wasn't obvious to me how to change to my composite 0 input with this release... anyone?

Code:
$ ivtvctl -h
Usage:
  -d, --device <dev> use device <dev> instead of /dev/video0
  -h, --help         display this help message
  -K, --passthrough <mode>
                     set passthrough mode: 1 = on, 0 = off [IVTV_IOC_PASSTHROUGH]
  --get-yuv-mode     display the current yuv mode
  --set-yuv-mode [param],[param]
                     set the current yuv mode
     param:
       mode        =<#> yuv_mode 0=interlaced,1=progressive,2=auto
       threshold   =<#> if src_hight <= threshold treat as progressive
  --reset-ir         reset the infrared receiver [VIDIOC_INT_RESET]
  --version          shows the version number of this utility.
                     It should match the driver version.

Expert options:
  -D, --set-debug <level>
                     set the module debug variable
                      1: WARN   2: INFO  4: API   8: DMA  16: IOCTL
                     32: I2C   64: IRQ 128: DEC 256: YUV 512: High Volume msgs
  -E, --end-gop      capture last GOP [IVTV_IOC_S_GOP_END]
  -e, --get-debug    query the module debug variable
  -I, --list-gpio
                     show GPIO input/direction/output bits
  -i, --set-gpio [dir=<dir>,]val=<val>
                     set GPIO direction bits to <dir> and set output to <val>
  -k, --sync         test vsync's capabilities [IVTV_IOC_FRAMESYNC]
  -R, --list-registers chip=<chip>,min=<addr>,max=<addr>
                     dump registers from <min> to <max> [VIDIOC_INT_G_REGISTER]
                     <chip> is one of: saa711x, saa7127, saa717x, cx2584x, cx2341x
  -r, --set-register chip=<chip>,reg=<reg>,val=<val>
                     set register [VIDIOC_INT_S_REGISTER]
                     <chip> is one of: saa711x, saa7127, saa717x, cx2584x, cx2341x
  -v, --audio-route=input=<in>,output=<out>
                     set the audio input/output routing [VIDIOC_INT_S_AUDIO_ROUTING]

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 22, 2008 10:21 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
You need to use the v4l2-ctl utility for this now. To show the available inputs:
Code:
v4l2-ctl --list-inputs

To select one:
Code:
v4l2-ctl --set-input=2

Also note that the v4l2 standardization means that all device names start at 1 now, so you're looking for "Composite 1" rather than "Composite 0". For more options:
Code:
v4l2-ctl --help | more

BTW - This is covered as Known Change #5.4 in the R5F27 Hints.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 22, 2008 10:49 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
As usual, you da man, tjc! Thanks for the speedy and accurate reply!

Video and audio out from the VCR or Handycam to the PVR-250's composite and audio in, then:

Code:
$ v4l2-ctl --set-input=5
$ cat /dev/video0 > test.mpg


Result is a beautiful mpeg-2!

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu