PDA

View Full Version : Need to get some infos in OGG/OGM/AVI/MPEG


NewAge-B
29th December 2002, 03:11
What is the proper way to read the properties of a AVI file? I mean the properties that is displayed if you right-click a AVI file in Windows and select Properties:

Picture size (width/height)
Sound length/bitrate/etc
Video bitrate/codec/etc

Any help appreciated.

Regards;
NewAge-B

Nosferatu
29th December 2002, 04:53
A proper way ?
Properties display true values if appriopriate codec is installed in the system, otherwise values might be invalid.

jggimi
29th December 2002, 05:07
http://www.doom9.org/Soft21/Editing/gspot20a.zip

NewAge-B
29th December 2002, 07:43
Originally posted by Nosferatu
A proper way ?
Properties display true values if appriopriate codec is installed in the system, otherwise values might be invalid.

My question was a bit too vague, I guess. What I want to do is to get to the properties in a program I am writing, so what I need is some documentation to how to (at least in part) parse the AVI file contents.

Regards;
NewAge-B

Zenitram
30th December 2002, 20:31
I am developing a tool which supplies information about a file:
- General information (title, author, director, album, track number, date, duration etc....)
- Information about the video (codec, aspect, fps, bitrate etc....)
- Information about the audio (codec, sample rate, channels, language, bitrate etc....)
- Information about the text (language of subtitle)
- Information about chapters (count of chapters, list)

But for some information, I don't know how to have them... How to have :
- in OGG or OGM : the duration in seconds of the file?
- in AVI or OGM : the bitrate of the video?
- for MPEG, is there a paper which describe how to handle them?

Suiryc
30th December 2002, 20:39
Originally posted by Zenitram
I am developing a tool which supplies information about a file:
- General information (title, author, director, album, track number, date, duration etc....)
- Information about the video (codec, aspect, fps, bitrate etc....)
- Information about the audio (codec, sample rate, channels, language, bitrate etc....)
- Information about the text (language of subtitle)
- Information about chapters (count of chapters, list)

But for some information, I don't know how to have them... How to have :
- in OGG or OGM : the duration in seconds of the file?
- in AVI or OGM : the bitrate of the video?
- for MPEG, is there a paper which describe how to handle them?
You have to parse the whole file in OGM to know the duration (or at least go at the end and hope you will find the last video data there : with the granulepos and the framerate you will get the duration).
For the bitrate you would have to read the whole OGM file, count how many bytes there are in the stream, and according to the duration of the stream you can compute (estimate) the bitrate.

Don't think you will find such a field (video bitrate) in AVI neither.

alexnoe
31st December 2002, 23:06
AVI files contain average bitrate values in the header, but they are nothing you should rely on, and some programs write wrong values thereto.

To obtain the correct average video bitrate of an AVI file, you need to parse the idx1 chunk (or indx-chunk of 1st stream in case of OpenDML, as well as all ix00 chunks if you want to obtain the correct length of an OpenDML file with broken dwDuration values, such as files written with VirtualDub 1.4.10 or earlier) and check the framerate in the strf-chunk of the video stream (NOT the dwMicroSecPerFrame-value in the main avi header: This one can be broken if someone used DirectShow for muxing of the file)

Zenitram
1st January 2003, 14:20
Agreed with you for average bitrate values in the header, I can't rely on it! This is why I am looking for another possibility...
But I use dwDuration and dwMicroSecPerFrame :(

OK for this method to have the good duration and framerate, but how have the bitrate with it? (I have thes size of the file, but not the size of video stream...)

Thanks!

alexnoe
1st January 2003, 22:46
You must read and process the entire index to get the overall size of the video stream :) If legacy index and opendml index are present, you can ignore the legacy index.

This is what I do in AVI-Mux GUI.

Zenitram
2nd January 2003, 00:26
Originally posted by NewAge-B
My question was a bit too vague, I guess. What I want to do is to get to the properties in a program I am writing, so what I need is some documentation to how to (at least in part) parse the AVI file contents.

Regards;
NewAge-B

alexnoe said it's not good, but actually I use AVIFileInfo like this :
AVIFileOpen(&Avi, Name, OF_READ, NULL);
AVIFileInfo(Avi, &AviInfo, sizeof(AviInfo));
AVIFileGetStream(Avi, &Stream, 0, 0);

So you will have thes details :
typedef struct {
DWORD dwMaxBytesPerSec;
DWORD dwFlags;
DWORD dwCaps;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwLength;
DWORD dwEditCount;
char szFileType[64];
} AVIFILEINFO;

See MS SDK for details...


alexnoe> Thanks, let's go to work, it is a lot harder! :)

alexnoe
2nd January 2003, 14:49
M$ writes crap obviously.

Another note:

The dwTotalFrames value is to contain the number of frames only in the first RIFF list! This is to make this part compatible to AVI 1.0.
M$ obviously doesn't remember that they have demanded this on Feb 27th, 1996, when they released OpenDML 1.02 specs: Any OpenDML file created with DirectShow will contain the overall total number of frames in that member.

The overall total number of video frames should be stored in the dmlh chunk, which is located in the odml list.

If you read the dwTotalFrames member to obtain the number of video frames, you'll get the correct number only for "small" AVI files and for "broken" files created with DirectShow, but not for correct files, e.g. created with AVI-Mux GUI or VirtualDub 1.4.11 or higher (in fact, the dis very value is also correct in older versions of VDub).

Anyway, I don't rely on either value, neither do I trust M$ implementations like VFW or DS, and have decided to parse the entire index in AVI-Mux GUI.
Imagine this: DirectShow does not open any OpenDML files with more than 3 audio streams. To implement even reading of such (correct) AVI files, you need to go "the hard way".

www.wotsit.org was where I got all my info on AVI files from.

Zenitram
2nd January 2003, 19:48
Originally posted by alexnoe
www.wotsit.org was where I got all my info on AVI files from.
Very good link (only for AVI, for others format it is not very complete :( )! I will try to do it.
Thank you.