From a510d3aa383a454e9454a9c55885010bba7fa2ec Mon Sep 17 00:00:00 2001 From: Aaron Vaage Date: Mon, 9 Jul 2018 14:39:33 -0700 Subject: [PATCH] Print Error and Ignore Text Samples With Bad Times Before we had an assert that would catch if a sample had an invalid times, however input may have bad times. We did have a message if we saw a sample with a duration equal to zero. This expands that check to check if the time is valid in general and will ignore any sample that is not valid. Fixes #425 Change-Id: I9774bfbdbd401f3016d2c345665b9973d1889db7 --- .../media/formats/webvtt/webvtt_parser.cc | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packager/media/formats/webvtt/webvtt_parser.cc b/packager/media/formats/webvtt/webvtt_parser.cc index 2297f6adb1..2e225a82e3 100644 --- a/packager/media/formats/webvtt/webvtt_parser.cc +++ b/packager/media/formats/webvtt/webvtt_parser.cc @@ -224,17 +224,21 @@ Status WebVttParser::ParseCue(const std::string& id, "Could not parse start time, -->, and end time from " + block[0]); } - // According to the WebVTT spec - // (https://www.w3.org/TR/webvtt1/#webvtt-cue-timings) end time must be - // greater than the start time of the cue. Since we are seeing content with - // zero-duration cues in the field, we are going to drop the cue instead of - // failing to package. + // According to the WebVTT spec end time must be greater than the start time + // of the cue. Since we are seeing content with invalid times in the field, we + // are going to drop the cue instead of failing to package. + // + // For more context see: + // - https://www.w3.org/TR/webvtt1/#webvtt-cue-timings + // - https://github.com/google/shaka-packager/issues/335 + // - https://github.com/google/shaka-packager/issues/425 // // Print a warning so that those packaging content can know that their // content is not spec compliant. - if (start_time == end_time) { - LOG(WARNING) << "WebVTT input is not spec compliant." - " Skipping zero-duration cue\n" + if (end_time <= start_time) { + LOG(WARNING) << "WebVTT input is not spec compliant. Start time (" + << start_time << ") should be less than end time (" << end_time + << "). Skipping webvtt cue:" << BlockToString(block, block_size); return Status::OK;