Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify Initial Sequence Number #270

Closed
sammirata opened this issue Sep 16, 2017 · 6 comments
Closed

Specify Initial Sequence Number #270

sammirata opened this issue Sep 16, 2017 · 6 comments
Labels
flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this type: enhancement New feature or request

Comments

@sammirata
Copy link
Contributor

sammirata commented Sep 16, 2017

Here is a sample command line:
packager-linux input=s00015072.ts.25274682549.ts,stream_selector=video,init_segment=video.mp4,segment_template=video2-$Number$.mp4

@sammirata
Copy link
Contributor Author

sammirata commented Sep 17, 2017

I answered my own question by looking at the code. There is no way to change the default of 1 as starting sequence number. Here is a patch that applies to latest version. It adds a new option to control the initial sequence number of the segmenter:

diff --git a/packager/app/muxer_flags.cc b/packager/app/muxer_flags.cc
index a18a4e7..888d486 100644
--- a/packager/app/muxer_flags.cc
+++ b/packager/app/muxer_flags.cc
@@ -50,3 +50,7 @@ DEFINE_bool(mp4_use_decoding_timestamp_in_timeline,
             "be used when generating media timeline, e.g. timestamps in sidx "
             "and mpd. This is to workaround a Chromium bug that decoding "
             "timestamp is used in buffered range, https://crbug.com/398130.");
+DEFINE_int32(mp4_sequence_number_initial,
+             1,
+             "This number allows for the customization of the "
+             "initial sequence_number in the mp4 moof->mfhd.");
\ No newline at end of file
diff --git a/packager/app/muxer_flags.h b/packager/app/muxer_flags.h
index a88a777..a096be4 100644
--- a/packager/app/muxer_flags.h
+++ b/packager/app/muxer_flags.h
@@ -20,5 +20,6 @@ DECLARE_int32(num_subsegments_per_sidx);
 DECLARE_string(temp_dir);
 DECLARE_bool(mp4_include_pssh_in_stream);
 DECLARE_bool(mp4_use_decoding_timestamp_in_timeline);
+DECLARE_int32(mp4_sequence_number_initial);
 
 #endif  // APP_MUXER_FLAGS_H_
diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc
index fa7e034..e9d41be 100644
--- a/packager/app/packager_main.cc
+++ b/packager/app/packager_main.cc
@@ -284,6 +284,7 @@ base::Optional<PackagingParams> GetPackagingParams() {
   mp4_params.use_decoding_timestamp_in_timeline =
       FLAGS_mp4_use_decoding_timestamp_in_timeline;
   mp4_params.include_pssh_in_stream = FLAGS_mp4_include_pssh_in_stream;
+  mp4_params.sequence_number_initial = FLAGS_mp4_sequence_number_initial;
 
   packaging_params.output_media_info = FLAGS_output_media_info;
 
diff --git a/packager/media/formats/mp4/segmenter.cc b/packager/media/formats/mp4/segmenter.cc
index 8e1bb56..dfbf84c 100644
--- a/packager/media/formats/mp4/segmenter.cc
+++ b/packager/media/formats/mp4/segmenter.cc
@@ -84,7 +84,7 @@ Status Segmenter::Initialize(
 
   // Use the reference stream's time scale as movie time scale.
   moov_->header.timescale = sidx_->timescale;
-  moof_->header.sequence_number = 1;
+  moof_->header.sequence_number = options_.mp4_params.sequence_number_initial;
 
   // Fill in version information.
   const std::string version = GetPackagerVersion();
diff --git a/packager/media/public/mp4_output_params.h b/packager/media/public/mp4_output_params.h
index f9b83f1..4c39dd8 100644
--- a/packager/media/public/mp4_output_params.h
+++ b/packager/media/public/mp4_output_params.h
@@ -29,6 +29,7 @@ struct Mp4OutputParams {
   /// which is needed to workaround a Chromium bug that decoding timestamp is
   /// used in buffered range, https://crbug.com/398130.
   bool use_decoding_timestamp_in_timeline = false;
+  int sequence_number_initial = 1;
 };
 
 }  // namespace shaka

@vaage
Copy link
Contributor

vaage commented Feb 8, 2018

@sammirata Sorry for the lack of communication. If you would like to contribute to the shaka packager, please follow the instructions in CONTRIBUTING and then provide a pull request.

@kqyang Would this be a change we would be willing to accept?

@kqyang
Copy link
Collaborator

kqyang commented Feb 9, 2018

Yes! I'd hope to have native support for HLS to DASH conversion, but since it is not going to happen soon, @sammirata's method is an effective way to make it work right now.

@sammirata Sorry for not getting back to you earlier. As suggested by @vaage, we welcome pull requests. A quick question, are there any clients / players requires the sequence_number to be set properly? I know Chrome does not care about the value.

@kqyang kqyang added the type: enhancement New feature or request label Feb 9, 2018
@vaage vaage added this to the Backlog milestone Feb 14, 2018
@vaage
Copy link
Contributor

vaage commented Feb 14, 2018

To make this issue appear nicer in the list of issues, I am going to rename it and move the description down here.

Is there a way to specify the sequence number when manually creating a single segment with a template? I could not find anything in the command line. I am working on a c# application that pulls HLS and converts it to HLS/fmp4 and Dash using the packager command line one segment at a time and the only thing I am missing is the sequence number assignment inside the mp4 files.

@vaage vaage changed the title Is there a way to specify the sequence number when manually creating a single segment with a template? I could not find anything in the command line. I am working on a c# application that pulls HLS and converts it to HLS/fmp4 and Dash using the packager command line one segment at a time and the only thing I am missing is the sequence number assignment inside the mp4 files. Specify Initial Sequence Number Feb 14, 2018
@sammirata
Copy link
Contributor Author

I have submitted a pull request with the patch. This method has been used effectively to generate a valid HLS/fmp4 stream using an HLS/ts as source.

@vaage vaage added the flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this label Mar 12, 2018
@vaage
Copy link
Contributor

vaage commented Mar 12, 2018

I have added the "Help Wanted" label since you submitted a pull request. The pull request is #350.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants