diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index e9efa6bc98..b3ffdcfb18 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -150,9 +150,11 @@ Status Segmenter::Initialize(const StreamInfo& info, } Status Segmenter::Finalize() { - uint64_t duration = - prev_sample_->pts() - first_timestamp_ + prev_sample_->duration(); - segment_info_.set_duration(FromBmffTimestamp(duration)); + if (prev_sample_) { + uint64_t duration = + prev_sample_->pts() - first_timestamp_ + prev_sample_->duration(); + segment_info_.set_duration(FromBmffTimestamp(duration)); + } return DoFinalize(); }