diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index b3ffdcfb18..52e4338124 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -150,7 +150,7 @@ Status Segmenter::Initialize(const StreamInfo& info, } Status Segmenter::Finalize() { - if (prev_sample_) { + if (prev_sample_ && !prev_sample_->end_of_stream()) { uint64_t duration = prev_sample_->pts() - first_timestamp_ + prev_sample_->duration(); segment_info_.set_duration(FromBmffTimestamp(duration)); diff --git a/packager/media/formats/webm/webm_muxer.cc b/packager/media/formats/webm/webm_muxer.cc index 5f1d516577..18e8a51dd0 100644 --- a/packager/media/formats/webm/webm_muxer.cc +++ b/packager/media/formats/webm/webm_muxer.cc @@ -47,7 +47,8 @@ Status WebMMuxer::InitializeMuxer() { } Status WebMMuxer::Finalize() { - DCHECK(segmenter_); + if (!segmenter_) + return Status::OK; Status segmenter_finalized = segmenter_->Finalize(); if (!segmenter_finalized.ok())