From ad95b9d8de3d116994dc556fa533f256b1761abe Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Fri, 22 Jul 2016 10:46:38 -0700 Subject: [PATCH] Fix text formats not recognized problem Also updated packager_test not to fill in output_format by default, which will help catch these kinds of bugs. Closes #130 Change-Id: I77157317de822d3f543f7e27d94bb4df7a1649d2 --- packager/app/test/packager_test.py | 36 +++++++++++++++----------- packager/media/base/container_names.cc | 10 +++++++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index 836c8283df..65a0426b14 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -403,7 +403,7 @@ class PackagerAppTest(unittest.TestCase): def _GetStreams(self, stream_descriptors, - output_format='mp4', + output_format=None, live=False, test_files=None): if test_files is None: @@ -422,25 +422,28 @@ class PackagerAppTest(unittest.TestCase): stream_descriptor) if live: if output_format == 'ts': - stream = ('input=%s,stream=%s,format=%s,' - 'segment_template=%s-$Number$.ts,playlist_name=%s.m3u8') - streams.append(stream % (test_file, stream_descriptor, - output_format, output_prefix, - stream_descriptor)) + stream = ('input=%s,stream=%s,segment_template=%s-$Number$.ts,' + 'playlist_name=%s.m3u8' % (test_file, stream_descriptor, + output_prefix, + stream_descriptor)) else: - stream = ('input=%s,stream=%s,format=%s,init_segment=%s-init.mp4,' - 'segment_template=%s-$Number$.m4s') - streams.append(stream % (test_file, stream_descriptor, - output_format, output_prefix, - output_prefix)) + stream = ( + 'input=%s,stream=%s,init_segment=%s-init.mp4,' + 'segment_template=%s-$Number$.m4s' % + (test_file, stream_descriptor, output_prefix, output_prefix)) + if output_format: + stream += ',format=%s' % output_format + streams.append(stream) self.output.append(output_prefix) else: output = '%s.%s' % ( output_prefix, self._GetExtension(stream_descriptor, output_format)) - stream = 'input=%s,stream=%s,format=%s,output=%s' - streams.append(stream % - (test_file, stream_descriptor, output_format, output)) + stream = ('input=%s,stream=%s,output=%s' % + (test_file, stream_descriptor, output)) + if output_format: + stream += ',format=%s' % output_format + streams.append(stream) self.output.append(output) return streams @@ -448,7 +451,10 @@ class PackagerAppTest(unittest.TestCase): # TODO(rkuroiwa): Support ttml. if stream_descriptor == 'text': return 'vtt' - return output_format + if output_format: + return output_format + # Default to mp4. + return 'mp4' def _GetFlags(self, encryption=False, diff --git a/packager/media/base/container_names.cc b/packager/media/base/container_names.cc index 4a4cdbbb4e..dbfeac90b6 100644 --- a/packager/media/base/container_names.cc +++ b/packager/media/base/container_names.cc @@ -1755,6 +1755,16 @@ MediaContainerName DetermineContainerFromFileName( } else if (base::EndsWith(file_name, ".ts", base::CompareCase::INSENSITIVE_ASCII)) { return CONTAINER_MPEG2TS; + } else if (base::EndsWith(file_name, ".vtt", + base::CompareCase::INSENSITIVE_ASCII)) { + return CONTAINER_WEBVTT; + } else if (base::EndsWith(file_name, ".ttml", + base::CompareCase::INSENSITIVE_ASCII)) { + return CONTAINER_TTML; + } else if (base::EndsWith(file_name, ".xml", + base::CompareCase::INSENSITIVE_ASCII)) { + // In our supported containers, only ttml is in xml format. + return CONTAINER_TTML; } return CONTAINER_UNKNOWN; }