[FFmpeg-devel] [PATCH] fftools/ffmpeg: Check AVPacket->duration for being positive not just non zero
Michael Niedermayer
michael at niedermayer.cc
Thu May 17 03:22:19 EEST 2018
Some demuxers (mov, microdvd at least) set duration negative.
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
fftools/ffmpeg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5a19a09d9a..3aa2175b5d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2619,7 +2619,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, &duration_pts, !pkt,
&decode_failed);
if (!repeating || !pkt || got_output) {
- if (pkt && pkt->duration) {
+ if (pkt && pkt->duration > 0) {
duration_dts = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
} else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) {
int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame;
@@ -2715,7 +2715,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
AVRational time_base_q = AV_TIME_BASE_Q;
int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate));
ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);
- } else if (pkt->duration) {
+ } else if (pkt->duration > 0) {
ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
} else if(ist->dec_ctx->framerate.num != 0) {
int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
--
2.17.0
More information about the ffmpeg-devel
mailing list