Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Display Modes
Old 21st January 2002, 13:49   #1  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
Length of a MPEG-2 File

I want to know how long (in frames or seconds etc) a MPEG-2 Movie file is with the simplest of ease (i.e. without decoding or searching through the whole file)

At present im doing it by looking at the timecode on the first Group-of-pictures & then looking at the timecode on the last GOP and working it out that way, but I doubt that's the best way of doing it...

Does any one else know a better way? Thanks alot for any help...

Cheers,
-Nic
Nic is offline   Reply With Quote
Old 21st January 2002, 20:34   #2  |  Link
dvd2svcd
Moderator
 
dvd2svcd's Avatar
 
Join Date: Oct 2001
Location: On top of the world!
Posts: 1,837
I don't think there is a better way. I too have searched for this answer, but when I saw that Brent Beyeler does it that same way in his avi2mpg2 (searching for last frame), I gave up and said to myself that that is probably the only way to do it. But I am still not 100% sure.
__________________
Cheers,
dvd2svcd
dvd2svcd is offline   Reply With Quote
Old 22nd January 2002, 09:37   #3  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
I have a small 2 min vob that has a timecode duration of about 4mins. So I dont think it's always correct & I doubt it is on Anime which is generally badly put together...

...But do you check the same thing as me (i.e. the time_code?). There must be a better way

Thanks for the reply, ill check out the source of avi2mpg & try a few other things.

Thanx again,
-Nic
Nic is offline   Reply With Quote
Old 2nd February 2002, 21:29   #4  |  Link
TelemachusMH
Just a kid at heart
 
TelemachusMH's Avatar
 
Join Date: Oct 2001
Location: Wouldn't you like to know ;-)
Posts: 272
How exactly are you doing it now? I have been trying to get that to work for some time now, and I didn't really get any help from the forums. What do you do to find the length?
TelemachusMH is offline   Reply With Quote
Old 3rd February 2002, 16:59   #5  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
I look at the first GOP and read the time code, then I jump towards the end of the file, & look at the last GOP and read the time code.

Try looking at bbtools, etc if im not explaing things quite correctly.

Cheers,
-Nic
Nic is offline   Reply With Quote
Old 3rd February 2002, 22:24   #6  |  Link
meisterproppa
Registered User
 
Join Date: Oct 2001
Posts: 14
I'm intersting

Hallo

i've a qustion too,
How can i count the frames in an mpeg file with delphi...
Big thx....
meisterproppa is offline   Reply With Quote
Old 3rd February 2002, 23:15   #7  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
Just happened across this link, dont know if it will help you

http://forums.delphiforums.com/bbMPEG_UG

-Nic
Nic is offline   Reply With Quote
Old 9th February 2002, 00:07   #8  |  Link
meisterproppa
Registered User
 
Join Date: Oct 2001
Posts: 14
@nic

Hallo Nic,

No, It doesn't help,I've posted my problem but no one answer....

Is there anybody who knows an solution, how can i realize it ????


thx
meisterproppa is offline   Reply With Quote
Old 18th July 2002, 14:22   #9  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
Ive finally had time into looking at getting some MPEG2 file info:

try my command prompt prog:
http://nic.dnsalias.com/MPEGInfo.exe

If anyones interested in the source ill post it here....its far simpler to read that most other info retreiving code....

-Nic
Nic is offline   Reply With Quote
Old 18th July 2002, 15:37   #10  |  Link
mpucoder
Moderator
 
Join Date: Oct 2001
Posts: 3,398
Reading the time code at beginning and end can really mislead you, since it does not have to be correct. The SCR would be more accurate, but then you're left with the question of how many frames/second. When working with NTSC, especially mixed progressive and interlaced, you're screwed. Since MPEG is a streaming protocol, there is no header (as in, e.g. AVI). The only way to get an accurate source frame count is to scan the entire file. The method you choose, of course, will depend on just how much accuracy you need.
mpucoder is offline   Reply With Quote
Old 18th July 2002, 15:57   #11  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,260
Thanks Mpucoder...Scanning through the whole file takes time though, so this will have to do for now. Ill look through the specs about the SCR & implement that too.

I was just bored yesterday at work in the morning & thought maybe someone could use it

-Nic
Nic is offline   Reply With Quote
Old 18th July 2002, 19:19   #12  |  Link
jj59
Registered User
 
Join Date: Dec 2001
Posts: 61
Maybe a bit of topic but perhaps mpeg2stat or mpeg2info can give some information.

mpeg2stat is at:
http://www.slac.com/ian/mpeg2stat.html
an article on some modifications is at:
http://citeseer.nj.nec.com/383404.html

mpeg2info is at:
http://www.cs.unc.edu/~kmp/dali_mpeg2_ext/

jj
jj59 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:30.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.