PDA

View Full Version : How to preserve aspect ratio using ffmpeg?


David1105
1st June 2007, 21:36
When using ffmpeg to convert a .mov file to .avi one, the following command line is used:

ffmpeg -i input.mov -y -f avi -vcodec xvid -vtag XVID -s 320x240 -acodec mp3 output.avi

The problem is that the aspect ratio (AR) of the original mov movie is changed in output movie. The AR of input movie is 16:9, however, the AR of output movie is changed to 4:3.

It seems like the ffmpeg defaults to 4:3 until you add a switch "-aspect 16:9" to the above command line. Is this correct?

We tried adding "-aspect 16:9" or "-aspect 1.7777" switch, however, the AR still looks like 4:3. Why the "-aspect" switch isn't working in such a case?

Is there a simple way to ask ffmpeg to preserve the AR of input movie? If not, there's a simple way to know AR of a input movie in advance before feeding the movie to ffmpeg for conversion?

Thanks!

bluesk1d
1st June 2007, 22:25
I dont have any experience with ffmpeg so maybe I'm missing something here but aren't you telling it to encode at a non16:9 resolution (320x240)? If you output to a 16:9 resolution, you shouldnt need to specify an aspect ratio. Even if you specify 16:9 as the AR, you are still encoding to 320x240 so that switch doesn't matter. It will squish it to fit. If you insist on a 320 horizontal res, do 320x180 (16:9).

Leak
1st June 2007, 23:04
Even if you specify 16:9 as the AR, you are still encoding to 320x240 so that switch doesn't matter. It will squish it to fit. If you insist on a 320 horizontal res, do 320x180 (16:9).
But that's exactly why you specify an aspect ratio when encoding, so the player will resize the 4:3 image to 16:9 on playback and you don't have to resize before encoding, something which is usually called "anamorphic encoding".

Happens with DVD all the time, and is also supported by XviD in an AVI file...

np: Kettel - Through Friendly Waters (Re: Through Friendly Waters)

celtic_druid
2nd June 2007, 02:20
Could try mencoder instead. Should detect input AR hopefully and set the output correctly. If not I have set the AR manually in the past and it worked fine.