diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py
index 194e16a193..e531da1d9d 100755
--- a/packager/app/test/packager_test.py
+++ b/packager/app/test/packager_test.py
@@ -271,6 +271,7 @@ class PackagerAppTest(unittest.TestCase):
output_file_prefix=None,
output_format=None,
segmented=False,
+ using_time_specifier=False,
hls=False,
trick_play_factor=None,
drm_label=None,
@@ -294,6 +295,8 @@ class PackagerAppTest(unittest.TestCase):
output_format: Specify the format for the output.
segmented: Should the output use a segmented formatted. This will affect
the output extensions and manifests.
+ using_time_specifier: Use $Time$ in segment name instead of using
+ $Number$. This flag is only relevant if segmented is True.
hls: Should the output be for an HLS manifest.
trick_play_factor: Signals the stream is to be used for a trick play
stream and which key frames to use. A trick play factor of 0 is the
@@ -358,8 +361,10 @@ class PackagerAppTest(unittest.TestCase):
stream.Append('init_segment', init_seg)
if segmented:
+ segment_specifier = '$Time$' if using_time_specifier else '$Number$'
segment_ext = GetSegmentedExtension(base_ext)
- seg_template = '%s-$Number$.%s' % (output_file_path, segment_ext)
+ seg_template = '%s-%s.%s' % (output_file_path, segment_specifier,
+ segment_ext)
stream.Append('segment_template', seg_template)
else:
if split_content_on_ad_cues:
@@ -1401,6 +1406,14 @@ class PackagerFunctionalTest(PackagerAppTest):
self._GetFlags(output_dash=True, generate_static_mpd=True))
self._CheckTestResults('live-static-profile')
+ def testLiveStaticProfileWithTimeInSegmentName(self):
+ self.assertPackageSuccess(
+ self._GetStreams(['audio', 'video'],
+ segmented=True,
+ using_time_specifier=True),
+ self._GetFlags(output_dash=True, generate_static_mpd=True))
+ self._CheckTestResults('live-static-profile-with-time-in-segment-name')
+
def testLiveProfileAndEncryption(self):
self.assertPackageSuccess(
self._GetStreams(['audio', 'video'], segmented=True),
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-0.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-0.m4s
new file mode 100644
index 0000000000..55ee417db1
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-0.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-45056.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-45056.m4s
new file mode 100644
index 0000000000..1ddbee3bdd
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-45056.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-89088.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-89088.m4s
new file mode 100644
index 0000000000..a7100e5c24
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-89088.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-init.mp4 b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-init.mp4
new file mode 100644
index 0000000000..1ba3d9abb9
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-audio-init.mp4 differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-0.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-0.m4s
new file mode 100644
index 0000000000..4dbca6653f
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-0.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-30030.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-30030.m4s
new file mode 100644
index 0000000000..da2f00a606
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-30030.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-60060.m4s b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-60060.m4s
new file mode 100644
index 0000000000..8dfe74ca5b
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-60060.m4s differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-init.mp4 b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-init.mp4
new file mode 100644
index 0000000000..aa3f67b37c
Binary files /dev/null and b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/bear-640x360-video-init.mp4 differ
diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd
new file mode 100644
index 0000000000..42da948f28
--- /dev/null
+++ b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packager/media/formats/mp4/multi_segment_segmenter.cc b/packager/media/formats/mp4/multi_segment_segmenter.cc
index 0ae18cb13f..cf12e4c170 100644
--- a/packager/media/formats/mp4/multi_segment_segmenter.cc
+++ b/packager/media/formats/mp4/multi_segment_segmenter.cc
@@ -92,6 +92,12 @@ Status MultiSegmentSegmenter::WriteSegment() {
DCHECK(fragment_buffer());
DCHECK(styp_);
+ DCHECK(!sidx()->references.empty());
+ // earliest_presentation_time is the earliest presentation time of any access
+ // unit in the reference stream in the first subsegment.
+ sidx()->earliest_presentation_time =
+ sidx()->references[0].earliest_presentation_time;
+
std::unique_ptr buffer(new BufferWriter());
std::unique_ptr file;
std::string file_name;
@@ -115,15 +121,8 @@ Status MultiSegmentSegmenter::WriteSegment() {
styp_->Write(buffer.get());
}
- if (options().mp4_params.generate_sidx_in_media_segments) {
- DCHECK(sidx());
- DCHECK(!sidx()->references.empty());
- // earliest_presentation_time is the earliest presentation time of any
- // access unit in the reference stream in the first subsegment.
- sidx()->earliest_presentation_time =
- sidx()->references[0].earliest_presentation_time;
+ if (options().mp4_params.generate_sidx_in_media_segments)
sidx()->Write(buffer.get());
- }
const size_t segment_header_size = buffer->Size();
const size_t segment_size = segment_header_size + fragment_buffer()->Size();