Hi,

Thanks for your reply. But I have one question about video packet pts/dts.


As we know, video coding support I, P, B picture in general. If video encoder 
adopts B picture, then output packets' pts will be different from dts. In this 
case, we can't simply set pts/dts to the number of output packets. How to 
handle this case?


Thanks!


B.R.


Andrew






在 2015-09-02 14:34:55,"Max Vlasov" <[email protected]> 写道:



On Wed, Sep 2, 2015 at 6:01 AM, qw <[email protected]> wrote:


I'm using avcodec_encode_video2() and avcodec_encode_audio2() to encode video 
and audio raw data respectively. Can the two encoding function calculate 
dts/pts/duration of output packets itself? Or I'll calculate those timestamp 
values by using other method? Does ffmpeg provide examples to calculate those 
timestamp values?




Basically the steps for both streams are (at least I use it for encoding)


- You initialize the stream codec.time_base with the preferred choice. The best 
is frame rate for video (for example Num=1,  Den = 25 for Pal video) and 
sample_rate for audio (Num = 1 Den 44100 for 44k sound). I suspect other 
choices might work, only have in mind that rounding errors might affect the 
accuracy of the final stream values


- Before calling avcodec_encode_*  function you set the packet pts value to the 
correspondent next one. For choices above you should increase the video value 
by one for video and the number of audio samples for audio.


- Before calling av_interleaved_write_frame you call  av_packet_rescale_ts 
providing the packet with the changes explained above, the codec time_base 
explained above and the stream time_base that is defined by the library (you 
don't set it yourself). 

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to