Log in

View Full Version : Convert mpg to avi using ffmpeg


David1105
14th March 2007, 01:02
I converted a MPG file to AVI, using ffmpeg of the following command line:

ffmpeg -i test.mpg -y -f avi -b 1150 -s 320x240 -r 29.97 -g 12 -qmin 3 -qmax 13 -ab 224 -ar 44100 -ac 2 test.avi

The I used another app to convert "test.avi" to a .flv file. However, the resultant FLV has audio-only, but no video.

Does anyone know what could be the problem?

Thanks!

Guest
14th March 2007, 01:16
Does test.avi have the audio? How did you convert it to FLV?

setarip_old
14th March 2007, 01:27
Hi!

Then again, does "test.avi" play video?

Guest
14th March 2007, 01:32
Oops, silly me. I read it exactly backwards. :)

I appreciate your politeness, setarip_old.

David1105
14th March 2007, 20:04
Yes, the test.avi does have both audio and video.

After converting MPG to AVI, then I use an app which uses DirectShow to convert the AVI to FLV.

ilovejedd
14th March 2007, 20:22
Hmm, it seems it's your other program that's experiencing some problems... Have you tested if converting from mpg to flv and from avi to flv using ffmpeg gives you working flvs?

Also, what are you using to play flvs?

David1105
14th March 2007, 20:50
Hmm, it seems it's your other program that's experiencing some problems... Have you tested if converting from mpg to flv and from avi to flv using ffmpeg gives you working flvs?

Also, what are you using to play flvs?

It has no problem to convert from MGP to FLV or AVI to FLV using ffmpeg, meaning the resultant FLV is playable.

It's also no problem to use the DirectShow app to convert from MGP to FLV or AVI to FLV using ffmpeg, meaning the resultant FLV is also playable.

The problem happens only when convert from MPG to AVI using ffmpeg and then from AVI to FLV using the DS app.

The FLV is played back using Windows Media Player. It has no problem to play other FLV file converted not in the way that has the problem.

ilovejedd
14th March 2007, 21:10
What did you use to play back AVI generated by ffmpeg? Can you open the AVI using VirtualDub? In your command line you didn't specify the -vcodec and -vtag. By default, ffmpeg uses mpeg4 to encode but the FourCC it assigns is FMP4 which might not be recognizable by XviD or DivX. Try opening the AVI with a FourCC Changer and choose DIVX or XVID as the new FourCC.

David1105
14th March 2007, 22:33
What did you use to play back AVI generated by ffmpeg?

WMP.

Can you open the AVI using VirtualDub? In your command line you didn't specify the -vcodec and -vtag. By default, ffmpeg uses mpeg4 to encode but the FourCC it assigns is FMP4 which might not be recognizable by XviD or DivX. Try opening the AVI with a FourCC Changer and choose DIVX or XVID as the new FourCC.

No.

Based on your suggestion I added "-vcodec xvid" and now the problem is fixed. Thanks!

Only couple of minor things, when trying to open the AVI file with VirtualDub, VirtualDub doesn't recognize xvid codec.

If using DivX for "-vcodec" in ffmpeg, ffmpeg doesn't recognize DivX.

Which one should use, VidX or DivX for the "vcodec" switch?

Also, in this page: http://www.free-codecs.com/guides/FourCC.htm, is there no VidX or DivX as registered FourCC code. Any explanation?

ilovejedd
14th March 2007, 22:54
That's because DivX is proprietary. Use -vcodec mpeg4 -vtag DIVX for DivX. As for xvid not being recognizable in VirtualDub, it's as simple as ffmpeg using xvid instead of XVID in the FourCC. Just add -vcodec xvid -vtag XVID to your commandline. That should fix it.

David1105
15th March 2007, 01:02
That's because DivX is proprietary. Use -vcodec mpeg4 -vtag DIVX for DivX. As for xvid not being recognizable in VirtualDub, it's as simple as ffmpeg using xvid instead of XVID in the FourCC. Just add -vcodec xvid -vtag XVID to your commandline. That should fix it.

A concern is that using "-vcodec xvid" here, does this cause MP4 video stream generated and contained in the output AVI file?

Since "Xvid is a video codec library following the MPEG-4 standard"...And I just want raw video data contained in the output AVI file.

ilovejedd
15th March 2007, 03:02
What exactly are you trying to do? Why are you converting to an intermediary format prior to conversion to FLV?

If you want lossless conversion from MPEG to AVI, you can use -vcodec huffyuv. Be aware that's going to give you humongous files.

David1105
15th March 2007, 16:55
What exactly are you trying to do? Why are you converting to an intermediary format prior to conversion to FLV?

Most of the conversion will use a DirectShow application. Some video files will be converted to .AVI using ffmpeg by others. Then we use the DirectShow app to convert to FLV.

If you want lossless conversion from MPEG to AVI, you can use -vcodec huffyuv. Be aware that's going to give you humongous files.

I tried "huffyuv", the output AVI file is very large as you said, but it's not playable by WMP.

Where is there a complete list of all options for "-vcodec" plus explanation?

Is "-vcodec mjpeg" referring to so-called lossless Motion JPEG?

What option should I use for "-vcodec" when other formats (like WMV, MP4, FLV etc.) of input file converting to AVI?