Dropped video frames from iOS 11 Screen Record Videos lead to an Unsynced video

Description

It seems like ffmpeg does not know how to handle videos that were recorded on iOS 11 through the native screen recording functionality.

We were taking the video stream and copying the second audio stream (from the microphone) and stitch it together so web players would be able to handle the audio portion properly.

We discovered that frames were dropped at the beginning of the converted video, but the audio still began on time. It seems like everything before the 2nd keyframe is dropped, as it can't locate the first keyframe. We believe this occurs due to a negative start timestamp on the video.

Output of this video has dropped video frames (approximately 10 seconds worth), while keeping the audio. This leads to an unsynced video. Even with flags like -copyts and other fixes we found online, we still ended up with dropped frames at the start of the video, i.e. a black screen.

We tried a fork of ffmpeg called libav, which seems to handle this file properly and doesn’t drop the frames at the start of the output video, between the first and second keyframe.