From 416051ae65365e88764edd3041e4242e416ead6c Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Wed, 1 Aug 2018 15:37:40 -0700 Subject: [PATCH] Avoiding segmentation fault on streams without samples An informational message is logged instead. Fixes #446. Change-Id: Ia3a79a16b3bdbabd5d56facf9bf011f29c9b1533 --- packager/media/formats/mp4/mp4_muxer.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index 6267727183..319727c75d 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -147,7 +147,16 @@ Status MP4Muxer::InitializeMuxer() { } Status MP4Muxer::Finalize() { - DCHECK(segmenter_); + // This happens on streams that are not initialized, i.e. not going through + // DelayInitializeMuxer, which can only happen if there are no samples from + // the stream. + if (!segmenter_) { + DCHECK(to_be_initialized_); + LOG(INFO) << "Skip stream '" << options().output_file_name + << "' which does not contain any sample."; + return Status::OK; + } + Status segmenter_finalized = segmenter_->Finalize(); if (!segmenter_finalized.ok())