Log in

View Full Version : Extracting the first timestamp of Mpeg2


ApPojken
6th June 2006, 19:39
Hi,

I am trying desperately to find a way to extract the first GOP timestamp of a Mpeg2-file. I've been searching and googeling for a long time without result.

I was looking at Nic's command line app "MPEGInfo.exe" which would have been absolutely perfect if it only worked. Unfortunately it doesn't work very well...

Anyone who has seen any other application or source code on how to extract the first time code from the Mpeg2 header information?

/ApPojken

hank315
6th June 2006, 21:49
Restream will show the first time code (and a lot of other info).

ApPojken
6th June 2006, 22:16
Hank315

Thanks for your answer. Actually I am aware of this. The only problem is that this program can't be put into an automated process. I am more after a command line tool or some simplified source code.

hank315
6th June 2006, 22:50
Here's some info how the time code is stored in the bitstream:
A MPEG file will start with 00 00 01 BA (pack start code), the video part starts with 00 00 01 B3 (sequence header code).
The time code is located in the GOP header which starts with 00 00 01 B8, this should be within a few hundred bytes after the sequence header code.
The first 25 bits after 00 00 01 B8 hold the time code:

- drop_frame_flag 1 bit
- time_code_hours 5 bits range 0 - 23
- time_code_minutes 6 bits range 0 - 59
- marker_bit 1 bit
- time_code_seconds 6 bits range 0 - 59
- tine_code_pictures 6 bits range 0 - 59

ApPojken
7th June 2006, 10:20
Thanks Hank! I think you have saved my day.

I'll just create some code for it. I can see the changes after 00 00 01 B8 when modifying the timestamp of my test clip.

medp7060
15th September 2007, 11:56
ANy progress?

I am looking a way to get the time/date stamp from the mpg recorded by a Sony DCR-SR82 Hard Disk Drive Camcorder. The camera stores MPEG-2 files. I can then transfer them to my computer via USB cable.