Why does frame-> pts increase by 20 rather than 1?

Following the examples of ffmpeg: decoding_encoding.c and filtering_video.c, I process one video file made by iPhone. Video file: .mov, video sizes; 480x272, video codec: H.264 / AVC, 30 frames per second, bit: 605 kbps.

First, I retrieve every frame that is YUV. I convert YUV to RGB24 and process RGB24 and then write RGB24 to a .ppm file. It shows that the .ppm file is correct.

Then I plan to encode the processed RGB24 frames into a video file. Since MPEG does not support the RGB24 image format, I used AV_CODEC_ID_HUFFYUV. But the output video file (showing 18.5 MB) does not play. Movie Player on Ubuntu reports an error: could not determine the type of stream. I also tried this on VCL. It just does not work without any errors.

My minor questions: For each extracted frame from the input video file, I get its pts as follows according to filtering_video.c:

frame->pts = av_frame_get_best_effort_timestamp(frame);

I print each frame of the frame and find that it is incremented by 20, as shown below:

pFrameRGB_count: 0,  frame->pts: 0
pFrameRGB_count: 1,  frame->pts: 20
pFrameRGB_count: 2,  frame->pts: 40
pFrameRGB_count: 3,  frame->pts: 60

Where frame is the extracted frame from the input video, and pFrameRGB_count is the counter for the processed frame in the form of RGB24.

Why are they wrong?

+5
source share
3 answers

H.264 video is used 90 kHz clockfor encoding timestamps. Since your video 30 fps, the PTS delta between two consecutive frames should be 3000instead 20.

A value of 20 indicates one or both of the following:

  • ( ) ( 600 ) 30

  • ( 4500 ).

PTS:

PTS delta = (1/fps) * Encoder sampling rate
+5

, , dec_ctx- > time_base.den = 1200; fps, 30, , (Ubuntu 12.04) , , 1200/30 = 40 . 20, frame- > pts = av_frame_get_best_effort_timestamp (frame);

= 20.

dec_ctx- > ticks_per_frame = 2. , ticks_per_frame 40 20. , , : = x ticks_per_frame (, , , ffmpeg, , time_base 1/ .)

0

, . - ffmpeg, . , , , : video_st- > time_base NOT video_st- > codec- > time_base

(a) :

packet- > dts * (1/video_st- > time_base.den)

(b) :

frame- > repeat_pict * (1/video_st- > time_base.den)

0

All Articles