[MPlayer-users] Converting AVI files to MPEG-1

emaillist+mpu at dogphilosophy.net emaillist+mpu at dogphilosophy.net
Wed Jun 19 06:13:02 CEST 2002


On Tuesday 18 June 2002 07:52 pm, GD Lewis wrote:
> Hey, does anyone have a clue as to how to go about using either MEncoder
> or Mplayer to convert avi movies to mpeg-1 format suitable for burning
> to VCD?
>
> The best I could think to do would be to use the -vo yuv4mpeg option and
> then pipe the stream thorugh the mjpegtools utilities like this:
>
> <mplayer -vo yuv4mpeg "source.avi" | yuvscaler -O VCD | mpeg2enc -f 1 -r
> 16 -o "target.mpg">

Close, but the basic concept works.  I HAVE used mplayer/mencoder to
create vcd's this way, in conjunction with the mjpeg tools (and, of course,
vcdimager and cdrdao).

One catch is that the yuv4mpeg output goes to a file called "stream.yuv"
instead of stdout, so instead you do:

mkfifo -m 660 stream.yuv

Then

mplayer -vo yuv4mpeg -oa null -vop scale=352:240 (if you want ntsc vcd size or 
352:288 for PAL) source.avi

and 

mpeg2enc -f 1 -o target.m1v < stream.yuv

will give you the video stream.

(I cheat - I open up a couple of Konsole sessions.  In one I start the 
mpeg2enc session - which 'pauses' while waiting for stuff to start
coming through stream.yuv, and then in the other session starting mplayer).

One note - you MAY need to convert to a different framerate, depending on your
source.  If the source file isn't either 23.976 or 29.970 for NTSC or 25 fps
for PAL, then you can convert it with mencoder, like:

mencoder -oac copy -ovc copy -ofps 29.970 -o newframerate.avi source.avi

which will duplicate or drop frames as necessary to make it correct (a handy
feature, I've found).

You'll still also need to convert the sound as well.  If I remember correctly, 
I couldn't get mp2enc to accept the sound as a pipe, unlike the video, so I 
had to extract it as a .wav file and mp2enc it separately

In summary, you ought to be able to convert a .avi with an appropriate 
framerate to a VCD as follows (there is almost certainly a simpler way to do
this with one window, but here's how I do it with 2) (these instructions are 
for NTSC.  PAL is similar):

In one window or Konsole session:

mkfifo -m 660 stream.yuv

mpeg2enc -f 1 -n n -F 4 (or -F 1 for 23.976 fps) -o output.m1v < stream.yuv

In the other window:

mplayer -vo yuv4mpeg -ao pcm -aofile output.wav -vop scale=352:240 -sws 2 
source.avi

you should see mplayer start up.  If you now switch back to the other window 
you should see the frame encoding messages from mpeg2enc are now flowing 
past.

When it's all done, do:

mp2enc -V -o output.mpa output.wav

Then when that finishes:

mplex -f 1 -o output.mpg output.m1v output.mpa

At this point, I usually do a quick playback with mplayer
to double-check the .mpg file, then go ahead and delete the
m1v, mpa, and wav files.

You now have a VCD ready .mpg.  Just make .bin and .cue files from
it with vcdimager and burn it to a cd-r with cdrdao and you're set.

I've actually gone through this procedure and it does work, so this
should be good for you until somebody pops up with a much simpler explanation
(possibly including "just use mencvcd", which is a script that you can get 
from cvs that does more or less what I've just described.  It may also be in
the "snapshots".)

Hope this long-winded explanation helps, at least a little...




More information about the MPlayer-users mailing list