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

Adding dash_only and hls_only parameters #721

Merged

Conversation

sr1990
Copy link
Contributor

@sr1990 sr1990 commented Feb 29, 2020

This PR is related to #651. Adding dash_only=true or hls_only=true will create DASH only or HLS only output.
Example:

$ packager \
  in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \
  in=input_text.vtt,stream=text,output=output_text.vtt \
  in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4, dash_only=true \
  in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4, hls_only=true  \
  in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4 \
  in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4 \
  --mpd_output h264.mpd --hls_master_playlist_output h264.m3u8

Copy link
Contributor

@kqyang kqyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this feature! Please see my comments.

CreateHlsListenersInternal(stream, stream_index, hls_notifier_)) {
combined_listener->AddListener(std::move(listener));

if (stream.dash_only || stream.hls_only) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify the code to:

Suggested change
if (stream.dash_only || stream.hls_only) {
if (mpd_notifier_ && !stream.hls_only) {
...
}
if (hls_notifier_ && !stream.dash_only) {
...
}

@@ -128,6 +128,11 @@ struct StreamDescriptor {
std::vector<std::string> dash_accessiblities;
/// Optional for DASH output. It defines Role elements of the stream.
std::vector<std::string> dash_roles;

/// Optional for DASH output. Set to true if only DASH output is needed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer rephrasing it as:

/// Set to true to indicate that the stream is for dash only.

similar below.

@@ -206,6 +210,14 @@ base::Optional<StreamDescriptor> ParseStreamDescriptor(
base::SplitString(iter->second, ";", base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
break;
case kDashOnlyField:
if (iter->second == "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you ok with using "1" or "0" to be consistent with "skip_encryption" in line 170?

We may also support all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with "1" or "0". Will make the change.

/// Optional for DASH output. Set to true if only DASH output is needed.
bool dash_only = false;
/// Optional for HLS output. Set to true if only HLS output is needed.
bool hls_only = false;
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test in packager_test.py?

One option is to modify it from https://github.com/google/shaka-packager/blob/master/packager/app/test/packager_test.py#L652 and use dash_only for audio and use hls_only for video. After writing the test, you can run the below command to generate the golden files for you.

$ ninja -C out/Debug
$ out/Debug/packager_test.py --test_update_golden_files=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add the test. Thanks for the commands.

/// Optional for DASH output. Set to true if only DASH output is needed.
bool dash_only = false;
/// Optional for HLS output. Set to true if only HLS output is needed.
bool hls_only = false;
};

class SHAKA_EXPORT Packager {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes have updated the mentioned files. Please review and let me know.

Copy link
Contributor

@kqyang kqyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM with a few more style nits.

Also, you are welcomed to add your name / your company name to https://github.com/google/shaka-packager/blob/master/AUTHORS and https://github.com/google/shaka-packager/blob/master/CONTRIBUTORS if you haven't.


--dash_only=0|1

Optional. Defaults to 0 if not specified. If it is set to 1, indicates the stream is DASH only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Max 80 characters per line. Same below.

$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \
in=input_text.vtt,stream=text,output=output_text.vtt \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4, dash_only=1 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the space between "," and "dash_only" same below.

@sr1990
Copy link
Contributor Author

sr1990 commented Mar 5, 2020

Hey @kqyang, do you know why Travis CI might have failed for BUILD_TYPE=Debug LIBPACKAGER_TYPE=static_library?

Copy link
Contributor

@kqyang kqyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. One last comment.

As for the Travis build failure, it seems to be an issue in the build bot. I have triggered the rebuild.


* Output DASH + HLS with dash_only and hls_only options

$ packager \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this example to use a practical use case?

For example, HLS requires WebVTT in text format while DASH supports only segmented WebVTT in mp4 format. So that is an excellent use case for the two flags.

    $ packager \
      'in=h264_baseline_360p_600.mp4,stream=audio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s' \
      'in=input_text.vtt,stream=text,init_segment=text/init.mp4,segment_template=text/$Number$.m4s',dash_only=true' \
      'in=input_text.vtt,stream=text,segment_template=text/$Number$.vtt',hls_only=true' \  
      'in=h264_baseline_360p_600.mp4,stream=video,init_segment=h264_360p/init.mp4,segment_template=h264_360p/$Number$.m4s' \
      'in=h264_main_480p_1000.mp4,stream=video,init_segment=h264_480p/init.mp4,segment_template=h264_480p/$Number$.m4s' \
      'in=h264_main_720p_3000.mp4,stream=video,init_segment=h264_720p/init.mp4,segment_template=h264_720p/$Number$.m4s' \
      'in=h264_high_1080p_6000.mp4,stream=video,init_segment=h264_1080p/init.mp4,segment_template=h264_1080p/$Number$.m4s' \
      --generate_static_live_mpd --mpd_output h264.mpd \
      --hls_master_playlist_output h264_master.m3u8


$ packager \
'in=h264_baseline_360p_600.mp4,stream=audio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s' \
'in=input_text.vtt,stream=text,init_segment=text/init.mp4,segment_template=text/$Number$.m4s',dash_only=true' \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I accidentally included an extra ' after "m4s", can you remove it? Same below.

@kqyang kqyang merged commit a1dd82d into shaka-project:master Mar 6, 2020
@kqyang
Copy link
Contributor

kqyang commented Mar 6, 2020

@sr1990 The PR has been merged. Thanks for the great work on this feature request!

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants