关于pts、dts、duration
来源:5-13 抽取音频数据(三)

慕妹8246037
2023-02-24
/// 课程代码
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
pkt.dts = pkt.pts;
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
疑问1: 如果in_stream, out_stream的采样率是一样的,那pts、dts、duration是不是就不用重新设置了?
疑问2: 假设in_stream, out_stream的采样率是不一样的, 那这三个数据不为何使用统一的av_rescale设置,比如下面
packet->pts = av_rescale_q(packet->pts, in_stream->time_base, out_stream->time_base);
packet->dts = av_rescale_q(packet->dts, in_stream->time_base, out_stream->time_base);
packet->duration = av_rescale_q(packet->duration, in_stream->time_base, out_stream->time_base);
疑问3: 采样率不同的时候,课程代码中pts,duration 都要重新依据time_base重新计算,为什么dts 直接等于了pts, 而不是依照time_base重新计算?
packet->dts = av_rescale_q(packet->dts, in_stream->time_base, out_stream->time_base);
抱歉啊老师,疑问有些多
写回答
1回答
-
李超
2023-02-25
pts和dts,是有在视频上才有可能不一样,音频两个是一样的。时间基的计算函数里有判断,如果需要改变他就改变,如果不需要改变他就不改变,因此无论时间基发没发生变化,我们都调一下这个函数,他自己会去判断。
00
相似问题