VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. I'm writing my own software that can save AVI files. But I'm having trouble getting it to play correctly in all software. It works fine in FFPlay, VLC Player, and Windows Media Player, but VirtualDub throws an error when trying to play it. So I know something must be wrong, but I don't know what. Here's some things I'm considering. I don't know what I should set padding granularity field in the main AVI header to. I would like to have it use a granularity of 1 byte, so I don't need to worry about padding at all, but I don't know if 1 is a valid value for this field.

    Another couple things have me confused. According to MSDN, the stream header "strh" specifies a frame rectangle https://msdn.microsoft.com/en-us/library/windows/desktop/dd318183%28v=vs.85%29.aspx , but the main header "avih" doesn't https://msdn.microsoft.com/en-us/library/windows/desktop/dd318180%28v=vs.85%29.aspx . Instead, the last 16 bytes are reserved (always set to 0). However this other website http://www.fastgraph.com/help/avi_header_format.html shows that the last 16 bytes comprise 4 DWORD fields. It has descriptions (but not names) for these extra fields. They are:
    time scale, typically 30
    data rate (frame rate = data rate / time scale)
    starting time, typically 0
    size of AVI data chunk in time scale units

    So I'm not sure if this is a new spec, but I can't find it on the Microsoft website anywhere.

    Any help here would be great. Thanks in advance.
    Quote Quote  
  2. I finally found what the problem was. My index wasn't calculated correctly. I had assumed that the dwSize field of index idx1 entries was supposed to specify the size of a complete 00db chunk (size of image data + size of header, which is width * height * bytes per pixel + 8 for uncompressed video) but apparantly this was incorrect. It worked correctly in all video playback software after I changed it so that the dwSize field of an index entry was just the size of the the image data (which is width * height * bytes per pixel). I wish this was more clearly spelled out in the AVI specification.

    And now onto a related issue. Certain header fields dealing with image data size.
    While these header fields appear to be more flexible and don't corrupt the video file if there's some variation, I would still like to make sure I am calculating them properly. The fields in the main header I'm talking about are:
    dwMaxBytesPerSec
    dwSuggestedBufferSize

    And the fields in the stream header I'm talking about are:
    dwSampleSize
    dwSuggestedBufferSize


    So far I have them calculated as follows in the main header:
    dwMaxBytesPerSec = (width * height * bytes per pixel + 8 ) * frame rate
    dwSuggestedBufferSize = width * height * bytes per pixel + 8

    and in the stream header:
    dwSampleSize = width * height * bytes per pixel
    dwSuggestedBufferSize = width * height * bytes per pixel + 8

    In doing this, I've assumed that a "sample" refers to the image data of a frame, but a "buffer" refers to the block of data that the player needs to handle in order to extract the image, in other words the entire 00db chunk, and therefore is 8 bytes larger than a "sample". And for the data rate (dwMaxBytesPerSec) I've assumed that the rate refers to the rate of the player handling all bytes processed during playback, including the 8 bytes at the start of each 00db chunk. Is this correct? Or am I making the same mistake here as I did in the idx1 entries? Unlike idx1 though, these header fields seem to be more flexible, and don't prevent playback if they are slightly off, but I'd still like to make sure that these header fields are being calculated correctly.

    Again, any help here would be great.
    Quote Quote  
  3. I want to learn programming. Can you give us your finally code?
    Last edited by acheter; 19th Sep 2016 at 17:34.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!