AnsweredAssumed Answered

How to calculate PTS

Question asked by Remus Mihail Prunescu on Jun 28, 2018
Latest reply on Aug 15, 2018 by Remus Mihail Prunescu

Dear NXP Community,


In my application frames per second varies somewhere between 15-25 fps, and in order to get the right playback of the video stream I think I need to calculate the presentation timestamp in my application code (the encoder is not doing it itself). In libimxvpuapi encoded_frame->pts just copies raw_frame->pts, so I guess the raw_frame->pts needs to be calculated by the application.


Looking around I found a formula for h264 streams (c++ - ffmpeg::avcodec_encode_video setting PTS h264 - Stack Overflow):

//Calculate PTS: (1 / FPS) * sample rate * frame number
//sample rate 90KHz is for h.264 at 30 fps
picture->pts = (1.0 / 30) * 90 * frame_count;


Has any of you used a similar formula or is there any official documentation for it?