View Full Version : Extracting timecode from mpg
lansing
1st February 2016, 09:19
I have a VHS captured mpg file, and in the middle of the video, the video went off sync for about 15 minutes. There're random frame drops that cause video speed up here and there, and I have no clue where to spot every one of them.
I tried to fix it by blind guessing every spot and slow them down accordingly base on the audio, but the process is so hard and very frustrating.
I've noticed that with the mpg on playback, if I seek to a spot in that problematic section, the video will be in sync for a couple of seconds before the video speed up again, so I thought that there should be a counter in the mpg that's keeping track of the frame speed, and eventually there a way to extract this timecode?
kuchikirukia
1st February 2016, 11:14
Tried remuxing it with the correct frame rate/duration?
thecoreyburton
1st February 2016, 14:08
Or potentially / additionally remuxing it to another format, it could be how the format is being handled.
raffriff42
1st February 2016, 14:56
there should be a counter in the mpg that's keeping track of the frame speed, and eventually there a way to extract this timecode?There is a piece of metadata attached to every frame called the "Presentation Time Stamp" and another one called "Display Time Stamp" - the time the media player should throw the frame on the screen (frames are decoded "out of order"). Play the file with ffprobe.exe (included with ffmpeg) using this batch file
http://forum.doom9.org/showthread.php?p=1692702#post1692702
You are probably going to be most interested in pkt_pts_time or best_effort_timestamp_time.
lansing
1st February 2016, 20:01
There is a piece of metadata attached to every frame called the "Presentation Time Stamp" and another one called "Display Time Stamp" - the time the media player should throw the frame on the screen (frames are decoded "out of order"). Play the file with ffprobe.exe (included with ffmpeg) using this batch file
http://forum.doom9.org/showthread.php?p=1692702#post1692702
You are probably going to be most interested in pkt_pts_time or best_effort_timestamp_time.
I have ran the video with the batch, the number on pkt_pts_time and best_effort_timestamp_time are identical on the problematic section
raffriff42
1st February 2016, 20:09
They are normally identical to one another, from the few samples I have seen. Frame to frame, they should progress at a uniform rate (1/framerate seconds)
lansing
1st February 2016, 20:22
So it doesn't work on my video?
lansing
2nd February 2016, 08:24
So after 2 days of thinking, I finally figured out a logical process to fix this. I'm using Adobe Premiere's "razor tool" and "rate stretch tool" to do this.
First sync a point from the start and end of the video to the audio, extends the video duration to match the audio. Then go to the middle of the video and find another sync point, split the video in half as session A and B base on that point, and then either stretch/shrink A or B on that point to sycn with the audio. Then find sync points in session A and B separately and repeat the process over and over again. And eventually the process will cover the entire video with sync point interval of a few seconds apart, and the problem will be fixed.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.