Log in

View Full Version : chanching the aspect ration of an AVI


rackham
23rd October 2007, 15:55
is it possible to change the aspect ration an avi is played wothout having to re-code it, set the ascpet ration (i use the VLC-player) with the player or using avi-synth ?

say, i start an avi and it's running in 1:1, but i want it to run in 16:9. would i have to use one of the ways i allready know, or is there some rather simple sollution, like setting font-sizes in subtitles ???


thx

LoRd_MuldeR
23rd October 2007, 21:15
is it possible to change the aspect ration an avi is played wothout having to re-code it, set the ascpet ration (i use the VLC-player) with the player or using avi-synth ?

say, i start an avi and it's running in 1:1, but i want it to run in 16:9. would i have to use one of the ways i allready know, or is there some rather simple sollution, like setting font-sizes in subtitles ???


thx
In AVI files the aspect ratio is not stored in the AVI Header, because there is no such field in the AVI Header.
Instead the PAR and/or DAR value is stored inside the video stream - if supported by the particular video format...

If the video stream of your AVI file is in the MPEG-4 ASP format (DivX, Xvid, etc.) then the solution is:
http://www.moitah.net/#MPEG4Modifier

foxyshadis
23rd October 2007, 21:55
If it's not, just mux it into something that does support container ratios, like mkv.

rvm
23rd October 2007, 22:33
mencoder can do it, without re-encoding the video:

mencoder -force-avi-aspect 16:9 -avc copy -oac copy video_in.avi -o video_out.avi


But probably most players (except mplayer) will ignore the setting.

foxyshadis
23rd October 2007, 22:52
That's because although there's an AR field in avi, most muxers will put garbage in it. mplayer has sanity checks, but once in a while it'll screw up playback of an otherwise valid video.

LoRd_MuldeR
23rd October 2007, 23:40
That's because although there's an AR field in avi, most muxers will put garbage in it.

I don't think there is in AR field in AVI, at least neither in the AVI Main Header nor in the AVI Stream Header structure.
The "dwWidth" value specifies the width of the AVI file in pixels and "dwHeight" value specifies the height of the AVI file in pixels.
So where does MEncoder place the AR info?
If MEncoder doesn't alter the video stream, I guess it places the AR info into some none-AVI chunck...



typedef struct {

DWORD dwMicroSecPerFrame;

DWORD dwMaxBytesPerSec;

DWORD dwReserved1;

DWORD dwFlags;

DWORD dwTotalFrames;

DWORD dwInitialFrames;

DWORD dwStreams;

DWORD dwSuggestedBufferSize;

DWORD dwWidth;

DWORD dwHeight;

DWORD dwScale;

DWORD dwRate;

DWORD dwStart;

DWORD dwLength;

} MainAVIHeader;


typedef struct {

FOURCC fccType;

FOURCC fccHandler;

DWORD dwFlags;

DWORD dwReserved1;

DWORD dwInitialFrames;

DWORD dwScale;

DWORD dwRate;

DWORD dwStart;

DWORD dwLength;

DWORD dwSuggestedBufferSize;

DWORD dwQuality;

DWORD dwSampleSize;

} AVIStreamHeader;

rvm
24th October 2007, 02:33
http://www.mplayerhq.hu/DOCS/HTML/en/aspect.html


13.10. Preserving aspect ratio

DVDs and SVCDs (i.e. MPEG-1/2) files contain an aspect ratio value, which describes how the player should scale the video stream, so humans will not have egg heads (ex.: 480x480 + 4:3 = 640x480). However when encoding to AVI (DivX) files, you have to be aware that AVI headers do not store this value. Rescaling the movie is disgusting and time consuming, there has to be a better way!

There is

MPEG-4 has a unique feature: the video stream can contain its needed aspect ratio. Yes, just like MPEG-1/2 (DVD, SVCD) and H.263 files. Regretfully, there are few video players apart from MPlayer that support this MPEG-4 attribute.

This feature can be used only with libavcodec's mpeg4 codec. Keep in mind: although MPlayer will correctly play the created file, other players may use the wrong aspect ratio.

homerjay
24th October 2007, 08:55
If the video stream of your AVI file is in the MPEG-4 ASP format (DivX, Xvid, etc.) then the solution is:
http://www.moitah.net/#MPEG4Modifier

Hi there quick question on this, think its relevant....

If I have a native 4:3 resolution being stretched onto a 16:9 LCD can this be used to make the avi display properly by selecting the pixel AR as 16:9 Pal and the display AR are 4:3 ?

rackham
24th October 2007, 09:29
thanks a lot guys !

LoRd_MuldeR
24th October 2007, 10:48
http://www.mplayerhq.hu/DOCS/HTML/en/aspect.html

So as said in my first post, the AR info is stored in the Video Stram (if at all) and not in the AVI container...

squid_80
24th October 2007, 13:08
I don't think there is in AR field in AVI, at least neither in the AVI Main Header nor in the AVI Stream Header structure.

Your definition of AVIStreamHeader is missing the rcframe struct. In theory it could be used to store an aspect ratio, but it's pointless to contemplate it since nothing would support it.

foxyshadis
25th October 2007, 04:50
Your definition of AVIStreamHeader is missing the rcframe struct. In theory it could be used to store an aspect ratio, but it's pointless to contemplate it since nothing would support it.

Ah, that's what it's called, I was searching the vdub blog looking for the reference I'd seen. I see even mplayer doesn't use that, so yeah, everything just writes garbage to it.

mplayer docs are a bit outdated, since most mpeg4 avi players (but not editors) support mpeg4 AR now, even in set-top players. At least that's a more portable method than mpeg4modifier, though, since no .net is needed.