ffmpeg copyts to preserve timestamp

梦想与她 提交于 2019-12-03 12:25:49

I decided to dig a little in the source to understand what's happening.

  • The overall start_time of the program is calculated by the using the presentation time stamp(PTS) of each individual stream in the file.

  • ffmpeg sets a default Mux decode delay value of 0.7 seconds. This is set in the ffmpeg_opt.c

This delay value is added to the PTS value of each packet, if the "copyts" flag is not set(in libavformat/mpegtsenc.c):

if (ts->copyts < 1) {
    if (pts != AV_NOPTS_VALUE)
        pts += delay;
    if (dts != AV_NOPTS_VALUE)
        dts += delay;
}

In this case, the encoder doubles the delay value :

const uint64_t delay = 
    av_rescale(s->max_delay, 90000, AV_TIME_BASE)*2;

Therefore, an extra 1.4 seconds get added to each packet's PTS. If "copyts" is provided, this is added to the timestamp value from the input stream.

It is possible to override this delay using the "muxdelay" flag; in that case the delay gets set to zero.

Now, why 0.7? why twice in the case of mpeg ts ?I wish I know the answers, presumably it's there in the spec somewhere. But for now, this would have to do.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!