View Full Version : Changing Embedded XVID aspect ratio?
wanton
25th May 2004, 18:35
Is there any utility to change xvid embedded aspect ratio? I've come across some video files that seems to have wrong aspect ratio in xvid encoded video and i don't seem to find any utility to fix it to correct one. I'm using XBOX Media Center that's based on mplayer. I have couple of files that are 640x480 resolution but show as 1.21 but are really 1.33 but for now i haven't found anyway to patch or remove aspect flags from avi file without re-encoding video.
Neo Neko
25th May 2004, 21:53
AFAIK there is no such software yet. It should be possible but no one has written it. I am also looking for it as well.
Zhnujm
25th May 2004, 22:11
Im also searching for that.
I tried to write a simple patching utility some time ago but it was more complicated than i thought, the values and the position where they are stored seem to change if you use different options in xvid.
And i have absolutely no idea how to really read the avi file structure. :D
Moitah
26th May 2004, 00:49
In which part of the AVI is the aspect ratio information stored?
mikeX
26th May 2004, 01:41
Totally wrong. The Open-DML AVI standard includes a VIDEOPROPERTYHEADER for video streams, which allows to indicate the output resolution in the sense of Matroska's DisplayWidth and DisplayHeight elements.
from Alex Noe's homepage (http://www-user.tu-chemnitz.de/~noe/Video-Zeug/AVIMux%20GUI/index-eng.html)
But what the application should do is change the AR in the MPEG4 bitstream, not in the particular container header (although that would make a nice addition)
Moitah
5th June 2004, 05:17
I am almost finished with a program that will change the aspect ratio in XviD AVIs. It was not a simple task, unfortunately. I hope to have it done and released within a few days, assuming no unforeseen problems.
SeeMoreDigital
5th June 2004, 12:17
Originally posted by Moitah
I am almost finished with a program that will change the aspect ratio in XviD AVIs... This sounds very interesting.
Will it be an XviD only application. And will the signalling work when the AVI stream is muxed into an MP4 container?
I can test MP4's in hardware if you like?
Cheers
Originally posted by Moitah
I am almost finished with a program that will change the aspect ratio in XviD AVIs. It was not a simple task, unfortunately. I hope to have it done and released within a few days, assuming no unforeseen problems. nice, as the ar is stored in the mpeg-4 bitstream, i assume your tool will work with all mpeg-4 bitstreams (like divx5, 3ivx aso..)?
SeeMoreDigital
5th June 2004, 15:58
Originally posted by bond
nice, as the ar is stored in the mpeg-4 bitstream, i assume your tool will work with all mpeg-4 bitstreams (like divx5, 3ivx aso..)? That's what I'm hoping for too!
Originally posted by SeeMoreDigital
That's what I'm hoping for too! i hope Moitah meant that his tool aims at editing the ar stored in the bitstreams, and not in the avi itself, as the editing of the info stored in the avi will not help anything, as the avi splitter from m$ ignores this info anyways (which means during playback in dshow there will not be a resize) :>
Moitah
5th June 2004, 17:06
The video must be in an AVI container, and OpenDML is not supported (maybe an AVI could be split into <1 gig pieces with VirtualDub, run the tool on each piece, and rejoin them). It should work on other MPEG-4 video streams inside AVI.
EDIT: Yes, it changes the aspect ratio stored in the MPEG-4 stream, not in any AVI headers.
SeeMoreDigital
5th June 2004, 17:11
Originally posted by Moitah
Yes, it changes the aspect ratio stored in the MPEG-4 stream, not in any AVI headers. Oooo, can't wait :)
Originally posted by Moitah
EDIT: Yes, it changes the aspect ratio stored in the MPEG-4 stream, not in any AVI headers. great! cant wait to test it out :)
The video must be in an AVI containerwhat about supporting .mp4 too? :D
its license free (meaning its totally legal to spread tools with .mp4 support) and opensource libraries are available from mpeg4ip (http://sourceforge.net/projects/mpeg4ip/) and gpac (http://sourceforge.net/projects/gpac) :)
Moitah
6th June 2004, 06:59
I have it working now, I will release a preview. It is written in C#, so you will need the .NET v1.1 Framework to run it (available at WindowsUpdate). It is command-line for now but I am most likely going to make it a GUI app.
Usage:
rp <src_path> <dest_path> <ar_info>
<ar_info> must be:
1 (Square Pixels)
2 (4:3 PAL Pixel Shape (12:11))
3 (4:3 NTSC Pixel Shape (10:11))
4 (16:9 PAL Pixel Shape (16:11))
5 (16:9 NTSC Pixel Shape (40:33))
par:<par_width>:<par_height> (Pixel Aspect Ratio)
dar:<frame_width>:<frame_height>:<dar_width>:<dar_height> (Display Aspect Ratio)
Examples:
rp c:\play.avi c:\play-new.avi 1
rp c:\play.avi c:\play-new.avi par:10:11
rp c:\play.avi c:\play-new.avi dar:640:480:16:9
EDIT: I will release the source code once I finish up a bit more.
EDIT2: Download link removed. See this thread (http://forum.doom9.org/showthread.php?s=&threadid=78050) for the new version.
ok i now tested the par option with a 3ivx, xvid and divx5 stream and it seems to work great :)
i tested the resize by remuxing from .avi to .mp4
i noticed that the display of the old ar stored is repeated various times. i assume thats because the value gets changed on every keyframe, right?
also its maybe important to mention that the options 2-5 will only work with DVD input, with SVCD input you will have to use other values if i understood it right.
xvid currently doesnt offer these values, but the 3ivx encoder does (if you want to find out which values these are)
also i noticed that by using .net the download increases from 5KB to 25MB :/
and .net tools will also not work on non windows systems if i understood it right, maybe it would have been better to write a commandline tool in a way its platform independant, but well i am no dev, i cant really say much about this...
thanks for this tool! :)
ps: what does "RP" stand for?
Zhnujm
6th June 2004, 13:50
Yes, thanks for your tool. :)
Too bad that i currently dont have the right hardware player to try it out.
SeeMoreDigital
6th June 2004, 14:19
I'm crap with 'non GUI' tools and can't make it work!
I would like to test an AVI to MP4 muxed stream (without B-VOP's) to see if they work in hardware :D
Can anybody post one please?
Cheers
mikeX
6th June 2004, 17:08
Moitah,
very nice to see this idea realised ;)
[b]
EDIT: I will release the source code once I finish up a bit more.
That would be great since it could attract people into changing your code to something more portable than C# and also attract interest into OpenDML AVI support (in case you don't plan supporting it yourself).
Best of luck ; )
Moitah
6th June 2004, 17:15
Originally posted by bond
ok i now tested the par option with a 3ivx, xvid and divx5 stream and it seems to work great :)
i tested the resize by remuxing from .avi to .mp4Thanks for testing :). I noticed VLC pays attention to the aspect ratio even when in an AVI container.
Originally posted by bond
i noticed that the display of the old ar stored is repeated various times. i assume thats because the value gets changed on every keyframe, right?Correct.
Originally posted by bond
ps: what does "RP" stand for?RIFF Parse. The first code I wrote was to build a RIFF tree in memory from a .avi, so thats what I named the project. It will be renamed when I make a proper release with GUI.
Don't mean to add stones to burden, but would it be possible to add custom resolutions?
(I'm currently wrangling '2001: A Space Odyssey', which has an AR of 2.21:1)
Originally posted by bot
Don't mean to add stones to burden, but would it be possible to add custom resolutions? as moitah wrote, its already possible when using
par:<par_width>:<par_height> (Pixel Aspect Ratio)
SeeMoreDigital
6th June 2004, 20:51
Originally posted by bot
Don't mean to add stones to burden, but would it be possible to add custom resolutions?
(I'm currently wrangling '2001: A Space Odyssey', which has an AR of 2.21:1) 2.21:1 eh!
On an PAL DVD this gives you 464 vertical image pixels and 112 (2 x 56) matte pixels.
On an NTSC DVD this gives you 384 vertical image pixels and 96 (2 x 48) matte pixels.
Did you crop away the mattes or keep them in?
If you kept them in just use just use either setting 4(PAL) or 5(NTSC). But without knowing more details about how Moitah's tool works I can't help you any further!
Cheers
minolta
6th June 2004, 21:11
hell ya! brought new life to my old 352x480 divx encodes:
rp divx.avi divx2.avi dar:352:480:4:3
i use xvid now, but i think this tool is even more important for the divx folks. thanks.
-Minolta
@bond ... Note to self: Pay more attention to posts with commands. :thanks:
@SeeMoreDigital ... I just ripped it from the (PAL) DVD last night. My Vdubmod has died and refuses to be resuscitated. So to get the image size, I played it in windvd:
It's anamorphic 720x576,
1.78:1 with cutoff panels
And a quick glance in photoshop gave ~2.21:1 with the panels removed.
I.e. the image ~720x326
So encoding it with panels intact with a 16:9 flag should get the desired aspect ratio. But if I want to remove the panels?
Zhnujm
6th June 2004, 22:01
If its an anamorphic DVD just use Setting 4 - 16:9 PAL.
It should not matter if you crop away the black bars as it sets the Pixel Aspect Ratio.
At least it works for me this way.
Of course! :scared:
Thanks!
SeeMoreDigital
6th June 2004, 22:18
When you say panels, do you mean the black bars (ie: the mattes).
For a list of the most commonly used ratio's and how the image and matte pixels compare, check out my list (http://SeeMoreDigital.net/03_Video_Only_Info/Image_Pixel_Frame_Size_Totals.html).
For more info about what an 'anamorphic' image actually looks like on an PAL DVD look here (http://SeeMoreDigital.net/03_Video_Only_Info/PAL_-_Anamorphicly_Encoded_Images.html).
Keep in mind you can't just capture DVD images and expect them to appear at the correct ratio via any photo imaging software. Although the height of the image will contain the correct quantity of pixels the width will not.... that's why they are called 'anamorphic'.
Cheers
Yes, I mean the mattes. I have a bad habit of calling the matte sheets you put on preview monitors 'panels'.
I have backed up anamorph DVD's with 16:9 flagged xvid before, but the films were always shot in 16:9. For some reason, it didn't cross my mind that the matte fields would be anamorphically warped too; I just looked at 2.21:1 and went "DUH".
The screencap in WinDVD produces correctly stretched (and in this case, upscaled to 1024x576 too) images.
Thanks all!
SeeMoreDigital
6th June 2004, 23:47
Hi bot,
An anamorphic image can be a difficult concept to grasp at first. There are two different methods of putting an anamorphic image on a DVD. The first is 4:3 anamorphic and the second is 16:9 anamorphic.
This is what a 2.35:1 AR image looks like when it's stored on a PAL (720x576) 16:9 'wide-screed' DVD: -
http://82.2.167.24/Uploaded_Files/Doom9_Forum_files/2.35.1_720x576_image.gif
As you can see it's all squashed up and it will remain this way until the appropriate player receives the 'anamorphic flagging signal' (buried in the video stream) to ping it out.
Cheers
mikeX
6th June 2004, 23:48
Moitah wrote
I noticed VLC pays attention to the aspect ratio even when in an AVI container.
Yes, non-directshow players such as VLC and mplayer (http://www.mplayerhq.hu/MPlayer/releases/win32-beta/) are able to read the AR information from the MPEG-4 bitstream.
SeeMoreDigital... Yes, here's some more numbers (for the trivia inclined gits like me): 2001 was shot in both 70mm Super Panavision (and 70mm Todd AO for special effects sequences), giving it an original aspect ratio of approximately 2.20:1. Most theatres didn't have the curved super panavision screen (or designated projector) to show it that way, so they used a 35mm anamorph super panavision print, giving an aspect ratio of approximately 2.34:1. The DVD is scanned and transcoded from the restored Super Panavision 65mm (!) print (2.28:1), retaining the 2.20:1 aspect ratio of the original print with matte. Now, can anyone blame me for being confused about the 2.21:1 display of a 1.78:1 anamorph representation of a 2.20:1 or 2.34:1 or 2.28:1 film :D
Anyway, good news about the progress of the AR flag changing utility!!
SeeMoreDigital
7th June 2004, 16:50
The way an anamorphic image is shot/placed on film has nothing to do with how it's telecined onto an DVD.
With regards to PAL (but the same goes for NTSC), there are many technical reasons why an 'anamorphic 16:9 frame' 720x576 was used and a 'true 16:9 frame' 1024x576 was not.
Sufficed to say in 1998/99 the Mpeg2 chip-sets may not have been up to the task, of crunching the additional 175,104 pixels required and the costs would certainly have been more. And don't forget DVB-T and S signals are anamorphic too!
Some time ago I talked about the quality benefits of re-encoding Mpeg2 720x576 'anamorphicly framed' images to Mpeg4 1024x576 'true 16:9 framed' images... many people on the forum could not see the point and thought it was a waste of time but some have changed their views.... It's one of those 'the hand is quicker than the eye' scenarios... but with pixels :)
Anyways, a movie at a cinema can in theory be presented using any aspect ratio, as a piece of film can be cropped and have mattes applied to form any AR size.
When you mentioned earlier that you had calculated the movies 2.21 AR to be 720x326 pixels, this intimated to me that you had not yet grasped the theory behind DVD anamorphics.
I hope you now understand that the 'horizontal' pixel axis is the anamorphic one. And the 'vertical' pixel axis is not - Regardless of weather mattes are used.
Cheers
Originally posted by SeeMoreDigital
When you mentioned earlier that you had calculated the movies 2.21 AR to be 720x326 pixels, this intimated to me that you had not yet grasped the theory behind DVD anamorphic. [/B]
Well, yes, I was referring to the (decoded and) 'decrunched' image. I knew the DVD was anamorphic. The original question came from my believing that just the 2.21:1 area of information (and not the excess matte area) had been squeezed into the anamorph frame: I thought I needed a 2.21:1 aspect ratio flag :rolleyes: .
-And I agree with you on the benefits of transcoding anamorphically.
SiXXGuNNZ
8th June 2004, 02:33
I can't get this to work, well, let me rephrase that. I can change the flag, but no media players will display it correctly. I tried. windows media player 10, media player classic, realplayer 10, zoomplayer pro, nero showtime and winamp 5.
I have only tired using the xvid decoder, do I need to use a different decoder?
mikeX
8th June 2004, 02:47
SiXXGuNNZ,
the tool changes the information in the MPEG-4 bitstream, not in the AVI headers. No directshow-based decoder/player combination can read that information from an AVI container (anyone correct me if I'm wrong).
You could either try remuxing the video to MP4 as bond did, or use VLC (http://www.videolan.org/), or mplayer (see my previous post for link).
SiXXGuNNZ
8th June 2004, 03:26
makes more sense then if it is a mp4 then, I read above that it changed the flag in the mp4 stream and not the avi, I did not realize it had to be an mp4 tho, I wish mp4's were a bit easier to make, I will try out mplayer, thanks :)
Originally posted by SiXXGuNNZ
I read above that it changed the flag in the mp4 stream and not the avithis tool does not change the AR in MP4 nor in AVI ;)
it changes the AR in the video bitstream itself
SeeMoreDigital
8th June 2004, 11:31
SiXXGuNNZ,
Nero's ShowTime player can display anamorphic AVI's and MP4's correctly as long as you swap it's DSdec filter over to this version (http://82.2.167.24/Uploaded_Files/Doom9_Forum_files/Nero_DSFilter_Fix.zip)!
Cheers
SeeMoreDigital
8th June 2004, 16:39
OK, seeing as though I'm a total thicky when it comes to no GUI based tools. Can somebody here change the AR of this DivX 720x576 2.35:1 clip (http://82.2.167.24/Uploaded_Files/Doom9_Forum_files/DivX_2pass_1B-VOP_Video Only.zip) for me and post it please.
Cheers
SiXXGuNNZ
15th June 2004, 05:18
Originally posted by SeeMoreDigital
SiXXGuNNZ,
Nero's ShowTime player can display anamorphic AVI's and MP4's correctly as long as you swap it's DSdec filter over to this version (http://82.2.167.24/Uploaded_Files/Doom9_Forum_files/Nero_DSFilter_Fix.zip)!
Cheers
I was wondering if you could get me that older filter again, I dunno where the copy I downloaded went
also, a gui is out for this app now :)
http://forum.doom9.org/showthread.php?s=&threadid=78050
SeeMoreDigital
15th June 2004, 10:17
Originally posted by SiXXGuNNZ
I was wondering if you could get me that older filter again, I dunno where the copy I downloaded went If you want another copy please just click on the link provided (it should still work). That said, I think I might have to include one or Nero's older parsers with it too, as the newer versions seem a bit wobbly with other apps.... even in WMP9.
And thanks, I'm going to give the new GUI version of the app a go right now :D
Cheers
SiXXGuNNZ
15th June 2004, 22:56
Originally posted by SeeMoreDigital
If you want another copy please just click on the link provided (it should still work). That said, I think I might have to include one or Nero's older parsers with it too, as the newer versions seem a bit wobbly with other apps.... even in WMP9.
And thanks, I'm going to give the new GUI version of the app a go right now :D
Cheers
thanks again :)
snowden
4th October 2007, 16:44
from Alex Noe's homepage (http://www-user.tu-chemnitz.de/~noe/Video-Zeug/AVIMux%20GUI/index-eng.html)
But what the application should do is change the AR in the MPEG4 bitstream, not in the particular container header (although that would make a nice addition)
what the hell is going on? read the third post here (the google snippet) http://www.google.com/search?hl=en&client=opera&rls=en&hs=cmt&q=edit+VIDEOPROPERTYHEADER&btnG=Search
and you will see it says the videopropertyheader is NOT supported by directshow. yet i thought in the rest of this post it is established that it is in fact the BITSTREAM that is not supported by directshow...can somebody clarify this?
SeeMoreDigital
4th October 2007, 16:52
Look at the dates of the posts in this thread...
Just about every MPEG-4 direct-show decoder I know of supports aspect ratio signalling detection now!
Cheers
snowden
4th October 2007, 16:58
yeah, funny thing is i was using a modded version of mpc (home theater), and it keeps the previous file position in memory...i just pressed the spacebar to pause it now, and the ar just changed. can't believe it! :lol:
EDIT: now it isn't working, i dunno what's going on. :(
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.