playback pace problem
tomisacat opened this issue · comments
Hello:
Recently I'm learning VideoToolbox, it's really appreciated that you provided such a great repo! But I still came across such a problem: the pace of playback is too fast. I tried another H.264 file but on the contrary it plays too slow, which is awkward. And this two file plays a normal speed in VLC or mpv. As we know that there's no presentation timestamp information in the H.264 file or stream, how do we control the pace of playback? BTW, I'm not clear about the CMTimeBase
, can this property of AVSampleBufferDisplayLayer
control the right speed?
Just find an article about Sequence Parameter Set(sps)
and it pointed out that sps
contains the information about frame rate:
the Sequence Parameter Set (SPS) and the Picture Parameter Set (PPS). Both entities contain information that an h.264 decoder needs to decode the video data, for example the resolution and frame rate of the video.
And apparently your project used the sps
and pps
to create the decompression session, so I wonder why it doesn't make sense? I've checked the presentation timestamp before decompression and after decompression, which is both with (value: 0, timescale: 0). Besides, it seems there's no function to get the frame rate or fps from the decomression session.
Well it turns out that the vui
in the sps
contains the information to determine the fps
, in specific, the time_scale
and num_units_in_tick
parameter, and the fps
could be calculated by time_scale / (2 * num_units_in_tick)
. So the problem turns into parsing sps
data, which is another question.