[FFmpeg-devel] [PATCH] avformat/movenc: fix duration in mdhd box
Martin Storsjö
martin at martin.st
Fri Dec 17 15:43:10 EET 2021
On Fri, 17 Dec 2021, Zhao Zhili wrote:
> It's the duration of this media, should not take account of
> editlist.
> ---
> libavformat/movenc.c | 9 +++++++--
> tests/ref/fate/movenc | 2 +-
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 0f912dd012..643beac6f2 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -2970,8 +2970,13 @@ static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track)
> static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
> MOVTrack *track)
> {
> - int64_t duration = calc_pts_duration(mov, track);
> - int version = duration < INT32_MAX ? 0 : 1;
> + int64_t start, end;
> + int64_t duration;
> + int version;
> +
> + get_pts_range(mov, track, &start, &end);
> + duration = end - start;
> + version = duration < INT32_MAX ? 0 : 1;
Isn't this equal to what calc_samples_pts_duration() returns?
It'd be good to point out in the commit message, that
c2424b1f35a1c6c06f1f9fe5f77a7157ed84e1cd was incorrect in this
aspect. It'd also be good to really spell it out clearly, that (if I
understand it correctly), mvhd and tkhd should present the post-editlist
duration, while mdhd should have the pre-editlist duration?
// Martin
More information about the ffmpeg-devel
mailing list