VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. Hi!

    I am writing a web application to read in MPEG-1, MPEG-2 and MPEG-4 files. I need to know the duration of the MPEG movie from the file itself.

    I know the equation: Duration = file size / bit rate X 8

    I am able to get the file size in my web application. I am also able to get the bit rate from the sequence header of the file.

    Problem is: I can only get the correct bit rate only for movies with 30fps. If the movie has 25 fps, the bit rate is wrong and the duration is wrong.

    Does anyone has any pointers for reading the bit rate of the movie? Are all the MPEG sequence headers the same? Is there a formula relating bit rate and frame rate?

    Any suggestions are appreciated. Thanks
    Quote Quote  
  2. Mod Neophyte redwudz's Avatar
    Join Date
    Sep 2002
    Location
    USA
    Search Comp PM
    Take a look at MediaInfo. It has some modules that can be incorporated in a program.

    Others here may have some better suggestions.

    And welcome to our forums.
    Quote Quote  
  3. You won't usually get the average bitrate from MPEG-2 files because anything can be written in the header. And if it's correct it's the max bitrate and not the average bitrate. Many will just say 9800, a completely meaningless number, whether 25fps or 29.97fps (or encoded as progressive 23.976fps). I don't know how you do find the average bitrate without parsing the entire file (the way Bitrate Viewer and DGIndex already do), but reading from the header isn't the right way. Why reinvent the wheel? Just use Bitrate Viewer and adapt it to your use.
    Quote Quote  
  4. Hi!

    Thanks for your replies. I have no choice but to parse the binary file of MPEG. I am unble to use external applications because I am writing a web application which does not apply interaction with the programs in the hard disk. Doing that would incur security risks on the user side.

    Does anyone know how people who write programs which read media files calculate the duration of the movie?

    Many thanks.
    Quote Quote  
  5. BTW, just an estimation of the duration is enough.
    Quote Quote  



Similar Threads

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