Skip to content

Commit bb104fe

Browse files
sr1990cosmin
andauthored
feat: get start number from muxer and specify initial sequence number (#879)
Set the start number in representation to the segment index that is sent by muxer. With this enhancement, you can now specify the initial sequence number to be used on the generated segments when calling the packager. With the old implementation, it was always starting with "1". --------- Co-authored-by: Cosmin Stejerean <[email protected]>
1 parent 62f861c commit bb104fe

File tree

91 files changed

+538
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+538
-359
lines changed

docs/source/options/chunking_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ Chunking options
2121

2222
Force fragments to begin with stream access points. This flag implies
2323
*segment_sap_aligned*. Default enabled.
24+
25+
--start_segment_number
26+
27+
Indicates the startNumber in DASH SegmentTemplate and HLS segment name.

include/packager/chunking_params.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct ChunkingParams {
3131
/// and mdat atom. Each chunk is uploaded immediately upon creation,
3232
/// decoupling latency from segment duration.
3333
bool low_latency_dash_mode = false;
34+
35+
/// Indicates the startNumber in DASH SegmentTemplate and HLS segment name.
36+
int64_t start_segment_number = 1;
3437
};
3538

3639
} // namespace shaka

packager/app/muxer_flags.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,9 @@ ABSL_FLAG(
7373
"If the first sample comes after default_text_zero_bias_ms then the start "
7474
"of the stream will not be padded as we cannot assume the start time of "
7575
"the stream.");
76+
77+
ABSL_FLAG(int64_t,
78+
start_segment_number,
79+
1,
80+
"Indicates the startNumber in DASH SegmentTemplate and HLS "
81+
"segment name.");

packager/app/muxer_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ ABSL_DECLARE_FLAG(std::string, temp_dir);
2222
ABSL_DECLARE_FLAG(bool, mp4_include_pssh_in_stream);
2323
ABSL_DECLARE_FLAG(int32_t, transport_stream_timestamp_offset_ms);
2424
ABSL_DECLARE_FLAG(int32_t, default_text_zero_bias_ms);
25+
ABSL_DECLARE_FLAG(int64_t, start_segment_number);
2526

2627
#endif // APP_MUXER_FLAGS_H_

packager/app/packager_main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ std::optional<PackagingParams> GetPackagingParams() {
360360
absl::GetFlag(FLAGS_segment_sap_aligned);
361361
chunking_params.subsegment_sap_aligned =
362362
absl::GetFlag(FLAGS_fragment_sap_aligned);
363+
chunking_params.start_segment_number =
364+
absl::GetFlag(FLAGS_start_segment_number);
363365

364366
int num_key_providers = 0;
365367
EncryptionParams& encryption_params = packaging_params.encryption_params;

packager/app/test/packager_test.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ def _GetFlags(self,
485485
use_fake_clock=True,
486486
allow_codec_switching=False,
487487
dash_force_segment_list=False,
488-
force_cl_index=None):
489-
488+
force_cl_index=None,
489+
start_segment_number=None):
490490
flags = ['--single_threaded']
491491

492492
if not strip_parameter_set_nalus:
@@ -575,6 +575,9 @@ def _GetFlags(self,
575575
elif force_cl_index is False:
576576
flags += ['--noforce_cl_index']
577577

578+
if start_segment_number is not None:
579+
flags += ['--start_segment_number', str(start_segment_number)]
580+
578581
if ad_cues:
579582
flags += ['--ad_cues', ad_cues]
580583

@@ -823,6 +826,13 @@ def testForcedSubtitle(self):
823826
output_hls=True))
824827
self._CheckTestResults('forced-subtitle')
825828

829+
def testDashStartNumber(self):
830+
audio_video_streams = self._GetStreams(['audio', 'video'], segmented=True)
831+
streams = audio_video_streams
832+
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True,
833+
start_segment_number=0))
834+
self._CheckTestResults('dash-start-number')
835+
826836
def testAudioVideoWithLanguageOverride(self):
827837
self.assertPackageSuccess(
828838
self._GetStreams(['audio', 'video'], language='por', hls=True),
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)