How can I programmatically delete frames from an mpg video and keep the audio in sync?

For the developers that use FFmpeg in their software.
Post Reply
mmsood
Posts: 5
Joined: Tue Oct 24, 2017 11:35 am

How can I programmatically delete frames from an mpg video and keep the audio in sync?

Post by mmsood » Wed Jan 17, 2018 3:14 am

I stream training videos from work, but don't have a great connection and get a lot of buffering. I have captured the streamed video from the PC screen into an mpg file. Fortunately when the video buffers, it shows a characteristic buffering icon in the center of the screen and there is no sound. Using ffmpeg, I have been able to write a c++ method that can step through the video frames of the mpeg file, convert to an RBG frame and detect the presence or absence of this characteristic buffering icon.

The final thing I need to do is generate a new mpeg file with only the frames that do not have this buffering image, and keep all the audio in sync. How do I do that with ffmpeg?

I have already found the dts and pts timestamps on the video and audio frames, but don't know how to use this information to recode just the frames that don't have the buffering image. The recode should keep all the properties of the original (framerate, resolution, size etc)

I can post the c++ code I have so far if that will help.

Thanks
mmsood99

Post Reply