From 43bea6c8c790939eeff853f8b8f62ce2f6636237 Mon Sep 17 00:00:00 2001 From: "lee.fordyce" Date: Mon, 13 May 2024 17:00:48 -0600 Subject: [PATCH] fix: negative duration from uint64 to int64 converstion --- packager/media/formats/mp4/mp4_media_parser.cc | 7 +++++-- packager/media/formats/mp4/mp4_muxer.cc | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packager/media/formats/mp4/mp4_media_parser.cc b/packager/media/formats/mp4/mp4_media_parser.cc index 4a02112578..98de99bfa6 100644 --- a/packager/media/formats/mp4/mp4_media_parser.cc +++ b/packager/media/formats/mp4/mp4_media_parser.cc @@ -410,9 +410,12 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) { // Calculate duration (based on timescale). int64_t duration = 0; - if (track->media.header.duration > 0) { + if (track->media.header.duration > 0 && + track->media.header.duration != std::numeric_limits::max()) { duration = track->media.header.duration; - } else if (moov_->extends.header.fragment_duration > 0) { + } else if (moov_->extends.header.fragment_duration > 0 && + moov_->extends.header.fragment_duration != + std::numeric_limits::max()) { DCHECK(moov_->header.timescale != 0); duration = Rescale(moov_->extends.header.fragment_duration, moov_->header.timescale, timescale); diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index c7425b8b44..64f0465780 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -248,7 +248,9 @@ Status MP4Muxer::DelayInitializeMuxer() { ftyp->compatible_brands.push_back(FOURCC_cmfc); // Carry over movie extends header duration from init segment. - moov->extends.header.fragment_duration = streams()[0].get()->duration(); + if (streams()[0].get()->duration() > 0) { + moov->extends.header.fragment_duration = streams()[0].get()->duration(); + } } moov->header.creation_time = IsoTimeNow();