diff --git a/packager/app/test/testdata/hls-segmented-webvtt/bear-subtitle-english-text-1.vtt b/packager/app/test/testdata/hls-segmented-webvtt/bear-subtitle-english-text-1.vtt index cf4aec6ee0..81150bae25 100644 --- a/packager/app/test/testdata/hls-segmented-webvtt/bear-subtitle-english-text-1.vtt +++ b/packager/app/test/testdata/hls-segmented-webvtt/bear-subtitle-english-text-1.vtt @@ -3,6 +3,3 @@ WEBVTT 00:00:00.000 --> 00:00:00.800 Yup, that's a bear, eh. -00:00:00.800 --> 00:00:01.000 - - diff --git a/packager/media/formats/webvtt/webvtt_output_handler.cc b/packager/media/formats/webvtt/webvtt_output_handler.cc index db8893a4ce..1f4c90d606 100644 --- a/packager/media/formats/webvtt/webvtt_output_handler.cc +++ b/packager/media/formats/webvtt/webvtt_output_handler.cc @@ -18,6 +18,8 @@ void WebVttOutputHandler::WriteCue(const std::string& id, uint64_t end_ms, const std::string& settings, const std::string& payload) { + DCHECK_GT(payload.size(), 0u); + // Build a block of text that makes up the cue so that we can use a loop to // write all the lines. const std::string start = MsToWebVttTimestamp(start_ms); @@ -148,7 +150,11 @@ Status WebVttSegmentedOutputHandler::OnTextSample(const TextSample& sample) { const std::string& settings = sample.settings(); const std::string& payload = sample.payload(); - WriteCue(id, start_ms, end_ms, settings, payload); + // Only write cues that have payloads. Cue without payloads won't present + // any information to the user. + if (payload.size()) { + WriteCue(id, start_ms, end_ms, settings, payload); + } return Status::OK; }