diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index 584a17b7f4..0f983c175c 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -100,6 +100,24 @@ class PackagerAppTest(unittest.TestCase): self._DiffGold(self.output[2], 'subtitle-english-golden.vtt') self._DiffGold(self.mpd_output, 'bear-640x360-avt-golden.mpd') + def testPackageAvcTs(self): + # Currently we only support live packaging for ts. + self.packager.Package( + self._GetStreams( + ['audio', 'video'], + output_format='ts', + live=True, + test_files=['bear-640x360.ts']), + self._GetFlags(live=True)) + self._DiffLiveGold(self.output[0], + 'bear-640x360-a-golden', + has_init_segment=False, + segment_extension='ts') + self._DiffLiveGold(self.output[1], + 'bear-640x360-v-golden', + has_init_segment=False, + segment_extension='ts') + def testPackageVp8Webm(self): self.packager.Package( self._GetStreams(['video'], @@ -378,10 +396,10 @@ class PackagerAppTest(unittest.TestCase): output_prefix = '%s_%d_%s' % (self.output_prefix, test_file_index, stream_descriptor) if live: - stream = ('input=%s,stream=%s,init_segment=%s-init.mp4,' + 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_prefix, - output_prefix)) + streams.append(stream % (test_file, stream_descriptor, output_format, + output_prefix, output_prefix)) self.output.append(output_prefix) else: output = '%s.%s' % ( @@ -491,13 +509,18 @@ class PackagerAppTest(unittest.TestCase): f.write(content.replace(test_output, 'place_holder')) self._DiffGold(media_info_output, golden_file_name + '.media_info') - def _DiffLiveGold(self, test_output_prefix, golden_file_name_prefix): + def _DiffLiveGold(self, + test_output_prefix, + golden_file_name_prefix, + has_init_segment=True, + segment_extension='m4s'): # Compare init and the first three segments. - self._DiffGold(test_output_prefix + '-init.mp4', - golden_file_name_prefix + '-init.mp4') + if has_init_segment: + self._DiffGold(test_output_prefix + '-init.mp4', + golden_file_name_prefix + '-init.mp4') for i in range(1, 4): - self._DiffGold(test_output_prefix + '-%d.m4s' % i, - golden_file_name_prefix + '-%d.m4s' % i) + self._DiffGold('%s-%d.m4s' % (test_output_prefix, i), '%s-%d.%s' % + (golden_file_name_prefix, i, segment_extension)) # Live mpd contains current availabilityStartTime and publishTime, which # needs to be replaced for comparison. diff --git a/packager/app/test/testdata/bear-640x360-a-golden-1.ts b/packager/app/test/testdata/bear-640x360-a-golden-1.ts new file mode 100644 index 0000000000..50d83fd065 Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-a-golden-1.ts differ diff --git a/packager/app/test/testdata/bear-640x360-a-golden-2.ts b/packager/app/test/testdata/bear-640x360-a-golden-2.ts new file mode 100644 index 0000000000..af2d499949 Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-a-golden-2.ts differ diff --git a/packager/app/test/testdata/bear-640x360-a-golden-3.ts b/packager/app/test/testdata/bear-640x360-a-golden-3.ts new file mode 100644 index 0000000000..5e060e766c Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-a-golden-3.ts differ diff --git a/packager/app/test/testdata/bear-640x360-v-golden-1.ts b/packager/app/test/testdata/bear-640x360-v-golden-1.ts new file mode 100644 index 0000000000..c8600d8422 Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-v-golden-1.ts differ diff --git a/packager/app/test/testdata/bear-640x360-v-golden-2.ts b/packager/app/test/testdata/bear-640x360-v-golden-2.ts new file mode 100644 index 0000000000..2b01f5cffc Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-v-golden-2.ts differ diff --git a/packager/app/test/testdata/bear-640x360-v-golden-3.ts b/packager/app/test/testdata/bear-640x360-v-golden-3.ts new file mode 100644 index 0000000000..713dcc5f77 Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-v-golden-3.ts differ diff --git a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc index a99300f8c4..79daf6c104 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc @@ -123,30 +123,29 @@ class Mp2tMediaParserTest : public testing::Test { TEST_F(Mp2tMediaParserTest, UnalignedAppend17) { // Test small, non-segment-aligned appends. - ParseMpeg2TsFile("bear-1280x720.ts", 17); - EXPECT_EQ(video_frame_count_, 80); + ParseMpeg2TsFile("bear-640x360.ts", 17); + EXPECT_EQ(video_frame_count_, 79); EXPECT_TRUE(parser_->Flush()); EXPECT_EQ(video_frame_count_, 82); } TEST_F(Mp2tMediaParserTest, UnalignedAppend512) { // Test small, non-segment-aligned appends. - ParseMpeg2TsFile("bear-1280x720.ts", 512); - EXPECT_EQ(video_frame_count_, 80); + ParseMpeg2TsFile("bear-640x360.ts", 512); + EXPECT_EQ(video_frame_count_, 79); EXPECT_TRUE(parser_->Flush()); EXPECT_EQ(video_frame_count_, 82); } TEST_F(Mp2tMediaParserTest, TimestampWrapAround) { - // "bear-1280x720_ptswraparound.ts" has been transcoded - // from bear-1280x720.mp4 by applying a time offset of 95442s - // (close to 2^33 / 90000) which results in timestamps wrap around - // in the Mpeg2 TS stream. - ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); + // "bear-640x360.ts" has been transcoded from bear-640x360.mp4 by applying a + // time offset of 95442s (close to 2^33 / 90000) which results in timestamps + // wrap around in the Mpeg2 TS stream. + ParseMpeg2TsFile("bear-640x360_ptswraparound.ts", 512); EXPECT_TRUE(parser_->Flush()); EXPECT_EQ(video_frame_count_, 82); - EXPECT_GE(video_min_dts_, static_cast(95443 - 1) * kMpeg2Timescale); - EXPECT_LE(video_max_dts_, static_cast(95443 + 4) * kMpeg2Timescale); + EXPECT_LT(video_min_dts_, static_cast(1) << 33); + EXPECT_GT(video_max_dts_, static_cast(1) << 33); } } // namespace mp2t diff --git a/packager/media/test/data/README b/packager/media/test/data/README index 682241bca9..1d35ae6a6c 100644 --- a/packager/media/test/data/README +++ b/packager/media/test/data/README @@ -26,8 +26,9 @@ vorbis-packet-2 - timestamp: 0ms, duration: 0ms vorbis-packet-3 - timestamp: 2902ms, duration: 0ms // Transport streams. -bear-1280x720.ts - AVC + AAC encode, multiplexed into an MPEG2-TS container. -bear-1280x720_ptswraparound.ts - Same as bear-1280x720.ts, with a timestamp wrap-around in the middle. +bear-640x360.ts - AVC + AAC encode, multiplexed into an MPEG2-TS container. +bear-640x360_ptswraparound.ts - Same as bear-640x360.ts, with a timestamp wrap-around in the middle, created with the below command: + ffmpeg -itsoffset 95442 -i bear-640x360.ts -c:v copy -c:a copy -muxdelay 0 bear-640x360_ptswraparound.ts // ISO-BMFF streams. bear-1280x720.mp4 - AVC + AAC encode, mulitplexed into an ISOBMFF container. diff --git a/packager/media/test/data/bear-1280x720.ts b/packager/media/test/data/bear-1280x720.ts deleted file mode 100644 index 8f4fee1caf..0000000000 Binary files a/packager/media/test/data/bear-1280x720.ts and /dev/null differ diff --git a/packager/media/test/data/bear-1280x720_ptswraparound.ts b/packager/media/test/data/bear-1280x720_ptswraparound.ts deleted file mode 100644 index 97215c395f..0000000000 Binary files a/packager/media/test/data/bear-1280x720_ptswraparound.ts and /dev/null differ diff --git a/packager/media/test/data/bear-640x360.ts b/packager/media/test/data/bear-640x360.ts new file mode 100644 index 0000000000..728209a609 Binary files /dev/null and b/packager/media/test/data/bear-640x360.ts differ diff --git a/packager/media/test/data/bear-640x360_ptswraparound.ts b/packager/media/test/data/bear-640x360_ptswraparound.ts new file mode 100644 index 0000000000..eb8396a348 Binary files /dev/null and b/packager/media/test/data/bear-640x360_ptswraparound.ts differ diff --git a/packager/media/test/packager_test.cc b/packager/media/test/packager_test.cc index 8db096ccc5..d23f50975c 100644 --- a/packager/media/test/packager_test.cc +++ b/packager/media/test/packager_test.cc @@ -27,7 +27,7 @@ namespace media { namespace { const char* kMediaFiles[] = {"bear-640x360.mp4", "bear-640x360-av_frag.mp4", - "bear-1280x720.ts"}; + "bear-640x360.ts"}; // Muxer options. const double kSegmentDurationInSeconds = 1.0;