Stream duration might not be reliable, let's not use if the frame size is known.
Signed-off-by: Marton Balint <c...@passwd.hu> --- libavformat/mov.c | 2 ++ tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 4 ++-- tests/ref/fate/gaplessenc-pcm-to-mov-aac | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 3fa8fcc..3574801 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5163,6 +5163,8 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t next_dts = (sc->current_sample < st->nb_index_entries) ? st->index_entries[sc->current_sample].timestamp : st->duration; pkt->duration = next_dts - pkt->dts; + if (sc->current_sample >= st->nb_index_entries && st->codec->frame_size && st->codec->sample_rate) + pkt->duration = av_rescale(st->codec->frame_size, sc->time_scale, st->codec->sample_rate); pkt->pts = pkt->dts; } if (st->discard == AVDISCARD_ALL) diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac index aacb058..e04934b 100644 --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac @@ -22,7 +22,7 @@ packet|pts=98304|dts=98304|duration=1024 packet|pts=99328|dts=99328|duration=1024 packet|pts=100352|dts=100352|duration=1024 packet|pts=101376|dts=101376|duration=1024 -packet|pts=102400|dts=102400|duration=1984 +packet|pts=102400|dts=102400|duration=1024 stream|nb_read_packets=102 frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024 @@ -39,5 +39,5 @@ frame|pkt_pts=98304|pkt_dts=98304|best_effort_timestamp=98304|pkt_duration=1024| frame|pkt_pts=99328|pkt_dts=99328|best_effort_timestamp=99328|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=100352|pkt_dts=100352|best_effort_timestamp=100352|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=101376|pkt_dts=101376|best_effort_timestamp=101376|pkt_duration=1024|nb_samples=1024 -frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=1984|nb_samples=1024 +frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=1024|nb_samples=1024 stream|nb_read_frames=101 diff --git a/tests/ref/fate/gaplessenc-pcm-to-mov-aac b/tests/ref/fate/gaplessenc-pcm-to-mov-aac index 05dff6e..16bed52 100644 --- a/tests/ref/fate/gaplessenc-pcm-to-mov-aac +++ b/tests/ref/fate/gaplessenc-pcm-to-mov-aac @@ -22,7 +22,7 @@ packet|pts=524288|dts=524288|duration=1024 packet|pts=525312|dts=525312|duration=1024 packet|pts=526336|dts=526336|duration=1024 packet|pts=527360|dts=527360|duration=1024 -packet|pts=528384|dts=528384|duration=1840 +packet|pts=528384|dts=528384|duration=1024 stream|nb_read_packets=518 frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024 @@ -39,5 +39,5 @@ frame|pkt_pts=524288|pkt_dts=524288|best_effort_timestamp=524288|pkt_duration=10 frame|pkt_pts=525312|pkt_dts=525312|best_effort_timestamp=525312|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=526336|pkt_dts=526336|best_effort_timestamp=526336|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=527360|pkt_dts=527360|best_effort_timestamp=527360|pkt_duration=1024|nb_samples=1024 -frame|pkt_pts=528384|pkt_dts=528384|best_effort_timestamp=528384|pkt_duration=1840|nb_samples=1024 +frame|pkt_pts=528384|pkt_dts=528384|best_effort_timestamp=528384|pkt_duration=1024|nb_samples=1024 stream|nb_read_frames=517 -- 2.6.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel