LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
Search this Thread
Old 02-21-2006, 05:43 AM   #1
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Rep: Reputation: 15
Converting mpeg4 to mpeg2 (mpeg4 to dvd)


I've captured some VHS video using a TV card and mencoder. Here's the command I used:

mencoder -tv driver=v4l:width=768:height=576 \
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=350:vhq:vqmax=31:keyint=300 \
-oac mp3lame -lameopts cbr:br=48 \
-vf crop=720:540:24:18,pp=lb,scale=384:288 -sws 1 -o output.avi tv://

So the video has been scaled down to 384x288. Incidentally, this leaves me with a 153MB file.

I could also use the command:

mencoder -tv driver=v4l:width=768:height=576 \
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900 \
-oac mp3lame -lameopts cbr:br=64 \
-vf crop=720:544:24:16,pp=lb -o output.avi tv://

This would avoid rescaling, although I'm sure I've read that you don't actually gain anything from recording VHS at 768x576 (or in this case 720x544) since the quality isn't that good to begin with. (NB: for anyone who's interested, these commands are from: http://www.mplayerhq.hu/DOCS/HTML/en/tv-input.html)

Anyway, whichever command I use, I'm left with an mpeg4. I want to convert that into a VOB (and AOB?) file so it can be played on a home DVD player (not just a computer's DVD player).

This is where I'm stuck. I tried tovid-interactive (as recommended here), but it seems to want to scale the video back up to 768x576 and threatens to take ~3000 hours to do it. Does anyone know how I can convert the mpeg4 to mpeg2/VOB using transcode (or even capture straight to mpeg2/VOB using mencoder)? Comments on resolution are also welcome (eg can/should I make the DVD at 384x288 ... or must I use 768x576?). Thanks!
 
Old 02-21-2006, 09:22 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
I usually use ffmpeg for this; it's much simpler and faster:

ffmpeg -i somefile.avi -y -target ntsc-dvd -aspect 16:9 -b 1800 somefile.mpg

Increase your video bitrate ("-b 1800" in the example to improve quality, but don't go over 5000). If your source is 4:3, update the aspect ratio in the example. All other attributes are set automatically by the '-target ntsc-dvd".
 
Old 02-21-2006, 07:07 PM   #3
jcliburn
Member
 
Registered: Dec 2003
Location: Mississippi, USA
Distribution: Fedora
Posts: 435

Rep: Reputation: 33
This may be an utterly stupid suggestion because I'm just learning about this topic, but could you encode directly to mpeg2 by using

-lavcopts vcodec=mpeg2video:vbitrate=900

Check the mencoder manpage and search for "vcodec=" to find all the options for the vcodec parameter.
 
Old 02-21-2006, 07:47 PM   #4
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
I do not reommend recording using a lossy codec like MPEG-4 when trying to output an MPEG-2.

Example capturing straight to a DVD compatible format from a TV source:
mencoder -tv driver=v4l:width=768:height=576 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192 :aspect=4/3 -ofps 25 -o movie.mpg tv://

The example above needs a very, very fast computer because it will only do about 8 frames per second on my Pentium 4 2.0 GHz (Northwood core) with 512 MB of RAMBUS memory. This means you need at least a computer that is three times faster than mine. You can get a MPEG-1/2 encoder card like Hauppauge PVR-250 (model 980).

I recommend using a lossless compression like huffyuv or something similar to it. Then use the command above or even better ffmpeg. I suggest using at least two hard drives in RAID level 0 and XFS as the filesystem.
 
Old 02-28-2006, 03:44 AM   #5
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
Macemoneta: Thanks for the suggestion. Unfortunately, ffmpeg returned: Unsupported codec (id=0) for input stream #0.0

jcliburn: I'm in the same boat as you. I'll try it out and report back.

Electro: I don't have those sort of resources for this project. Do many people have a machine "about three times faster" than a 2.0GHz? Last time I checked, a single core 6.0GHz required massively overclocking something in the 3.6GHz range. And liquid nitrogen to cool it.
 
Old 02-28-2006, 09:34 AM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Quote:
Originally Posted by conn-fused
Macemoneta: Thanks for the suggestion. Unfortunately, ffmpeg returned: Unsupported codec (id=0) for input stream #0.0
Have you installed the "All" codecs package from here? There is an included README file with installation instructions.
 
Old 02-28-2006, 01:45 PM   #7
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Quote:
I don't have those sort of resources for this project. Do many people have a machine "about three times faster" than a 2.0GHz? Last time I checked, a single core 6.0GHz required massively overclocking something in the 3.6GHz range. And liquid nitrogen to cool it.
Yes, few people own it, but is not from Intel. AMD Athlon FX-57 or Athlon FX-60 is close to three times faster.

It was a 3.2 GHz Pentium 4 (Prescott core) overclocked to 7 GHz with liquid nitrogen. It is not stable enough play games, so it will be impossible to use for video recording.
 
Old 03-03-2006, 03:14 AM   #8
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
OK, here are commands that will go from VHS -> MPEG2 -> DVD (thanks for that idea jcliburn) :

mencoder -tv driver=v4l:width=352:height=288 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=352:288,pp=lb,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192 :aspect=4/3 -ofps 25 -o YourMovie.mpg tv://

Now create an xml file that you can pass to dvdauthor. If you don't need menus or chapters (just drop in and play), this is as easy as:

Code:
<dvdauthor dest="dvd/">
   <vmgm />
   <titleset>
      <titles>
         <pgc>
            <vob file="YourMovie.mpg" />
         </pgc>
      </titles>
   </titleset>
</dvdauthor>
dvdauthor -x dvdauthor.xml
mkisofs -dvd-video -o YourMovie.iso dvd/

Then burn the resultant iso to dvd using a utility like k3b.

VHS converted to DVD in this way has worked in all the players I've tested so far. As a bonus, it's not too hard on the processor. I've even done it successfully on an 800Mhz Pentium.

I hope this helps someone! If I'm feeling ambitious later, I'll wrap this up in some perl:Tk and create a little GUI for VHS2DVD that will accept the length of the movie and stop mencoder at the right time. Otherwise, you have to pay attention to what you're capturing and interrupt mencoder when it's done.

Last edited by conn-fused; 03-03-2006 at 03:15 AM.
 
Old 03-03-2006, 03:57 PM   #9
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Quote:
Originally Posted by conn-fused
OK, here are commands that will go from VHS -> MPEG2 -> DVD (thanks for that idea jcliburn) :

mencoder -tv driver=v4l:width=352:height=288 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=352:288,pp=lb,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192 :aspect=4/3 -ofps 25 -o YourMovie.mpg tv://

Now create an xml file that you can pass to dvdauthor. If you don't need menus or chapters (just drop in and play), this is as easy as:

Code:
<dvdauthor dest="dvd/">
   <vmgm />
   <titleset>
      <titles>
         <pgc>
            <vob file="YourMovie.mpg" />
         </pgc>
      </titles>
   </titleset>
</dvdauthor>
dvdauthor -x dvdauthor.xml
mkisofs -dvd-video -o YourMovie.iso dvd/

Then burn the resultant iso to dvd using a utility like k3b.

VHS converted to DVD in this way has worked in all the players I've tested so far. As a bonus, it's not too hard on the processor. I've even done it successfully on an 800Mhz Pentium.

I hope this helps someone! If I'm feeling ambitious later, I'll wrap this up in some perl:Tk and create a little GUI for VHS2DVD that will accept the length of the movie and stop mencoder at the right time. Otherwise, you have to pay attention to what you're capturing and interrupt mencoder when it's done.
jcliburn added an incompatible DVD format. Again people still ignore my posts. I post the correct format that I got from mplayer's documentation.

An 800 MHz computer can not and I'll repeat again can not handle MPEG-2 encoding from a TV capture card because the inefficiencies of the ffmpeg code.

A proper DVD format have to be 640x576 or 720x576 for PAL. You can get by using 352x288 but not all DVD players will work with it.

I recommend using ffvhuff, a lossless codec based on Huffyuv that is supposely 20% smaller than Huffyuv that uses YV12, Then do the encoding to DVD. You can use avidemux to edit it.

For dvdauthor, you just need to type 'dvdauthor -o finaldvd YourMovie.mpg ; dvdauthor -T finaldvd'. The option -T is not in the manual but it is recommended to make the DVD work. Always after dvdauthor is done try testing to find out if it actually works.

mplayer -dvd-device finaldvd dvd://

If it works you can just put it on a DVD. Putting it through an ISO file is useless. Just make sure the directories VIDEO_TS and AUDIO_TS is on the DVD.
 
Old 03-04-2006, 11:00 AM   #10
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
Quote:
jcliburn added an incompatible DVD format. Again people still ignore my posts. I post the correct format that I got from mplayer's documentation.

An 800 MHz computer can not and I'll repeat again can not handle MPEG-2 encoding from a TV capture card because the inefficiencies of the ffmpeg code.

A proper DVD format have to be 640x576 or 720x576 for PAL.
This just isn't true. Look at the mplayer docs here:

http://www.mplayerhq.hu/DOCS/HTML/en...t-vcd-dvd.html

As you can see, 720x576, 704x576, 352x576, and 352x288 (Mpeg2) are all valid PAL formats.

Quote:
You can get by using 352x288 but not all DVD players will work with it.
I haven't found one of these DVD players yet, and based on the formats I posted above, it looks like it would be non-standard. Anyway, people can test these commands on their own players if they're interested. Your suggestions may provide superior results, but if no one has a machine capable of implementing them, what help do they provide?
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting mpeg4 to mpeg1 using mencoder not working slothpuck Linux - Software 4 10-25-2005 02:24 PM
subtitles mpeg4 mplayer shanenin Linux - Software 0 10-11-2004 09:31 PM
re-encoding mpeg4 robot5x Linux - Software 2 09-28-2004 05:20 AM
Mplayer and mpeg4 mikis Linux - Software 7 06-25-2004 03:06 PM
Mpeg4 encoder Nanu Linux - Software 4 04-27-2003 04:44 AM


All times are GMT -5. The time now is 03:50 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 Google+: linuxquestions
Open Source Consulting | Domain Registration