Calculate PTS before frame encoding in FFmpeg
问题 How to calculate correct PTS value for frame before encoding in FFmpeg C API? For encoding I'm using function avcodec_encode_video2 and then write it by av_interleaved_write_frame . I found some formulas, but no one of them doesn't work. In doxygen example they are using frame->pts = 0; for (;;) { // encode & write frame // ... frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); } This blog says that formula must be like this: (1 / FPS) * sample rate * frame number