This code runs post-demuxing and is not synchronized with the decoder
output (which may be delayed with respect to its input by arbitrary and
unknowable amounts), so accessing any decoder properties is incorrect.
---
 fftools/ffmpeg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 817b643c48..ca6ff780c3 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1856,7 +1856,7 @@ static void ist_dts_update(InputStream *ist, AVPacket 
*pkt)
 
     if (!ist->saw_first_ts) {
         ist->first_dts =
-        ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames 
* AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
+        ist->dts = ist->st->avg_frame_rate.num ? - ist->par->video_delay * 
AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
         if (pkt->pts != AV_NOPTS_VALUE) {
             ist->first_dts =
             ist->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q);
@@ -1889,11 +1889,11 @@ static void ist_dts_update(InputStream *ist, AVPacket 
*pkt)
             ist->next_dts = av_rescale_q(next_dts + 1, 
av_inv_q(ist->framerate), time_base_q);
         } else if (pkt->duration) {
             ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, 
AV_TIME_BASE_Q);
-        } else if(ist->dec_ctx->framerate.num != 0) {
+        } else if (ist->par->framerate.num != 0) {
             int fields = (ist->codec_desc &&
                           (ist->codec_desc->props & AV_CODEC_PROP_FIELDS)) ?
                          ist->last_pkt_repeat_pict + 1 : 2;
-            AVRational field_rate = av_mul_q(ist->dec_ctx->framerate,
+            AVRational field_rate = av_mul_q(ist->par->framerate,
                                              (AVRational){ 2, 1 });
 
             ist->next_dts += av_rescale_q(fields, av_inv_q(field_rate), 
AV_TIME_BASE_Q);
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to