shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.95k stars 505 forks source link

Output multiple manifest files with track selection #709

Open hariszukanovic opened 4 years ago

hariszukanovic commented 4 years ago

System info

All

Issue and steps to reproduce the problem

My problem is that some players (out of my control) are unable to recognise a track they are unable to decode and render correctly... ending up in an error state when they have switched to it... A simple example would be a mix of interlaced and progressive video tracks when de-interlacing is not supported on some devices. Player is usually playing but it does not de-interlace... which of course is very ugly. Another example would be to serve to some clients only lower resolution bitrates, others again (like Smart TV) serve only higher resolutions.

I would like to generate multiple manifest files (Dash) where I would make a selection of tracks to carry in each of them. The point of multiple manifests is that I want to avoid packaging multiple times and producing different chunk files for any combination and thus waisting a lot of storage.

I would like to package each track only once and then decide whether to include it in each of the generated manifests...

I have considered

In fact, I have done this myself using on-the-fly dynamic HLS playlist generator, but it seems not be as easily doable with Dash

kqyang commented 4 years ago

@hariszukanovic We don't support it directly right now, but there is a workaround. We actually bundle a mpd generator in our releases, which can be used to do what you have described here. Here is a sample command:

$ ./packager in=stream1.mp4,stream=video,out=video1.mp4 \
             in=stream1.mp4,stream=audio,out=audio1.mp4 \
             in=stream2.mp4,stream=video,out=video2.mp4 \
             in=stream2.mp4,stream=video,out=audio2.mp4 \
             --output_media_info

Then you can feed the generated .media_info to mpd_generator. For example, you can generate two DASH mpds with the first one containing all streams and the second one containing only streams from stream1.mp4, i.e.

$ ./mpd_generator --input="video1.mp4.media_info,audio1.mp4.media_info,video2.mp4.media_info,audio2.mp4.media_info" \
                  --output=all_streams.mpd
$ ./mpd_generator --input="video1.mp4.media_info,audio1.mp4.media_info" \
                  --output=stream1.mpd

There are some limitations, e.g. it only works for VOD.

@hariszukanovic Let us know if it works for you.

hariszukanovic commented 4 years ago

@kqyang Thanx for the workaround pointer. We do need this for both LIVE and VOD, but primarily for LIVE

krzemienski commented 4 years ago

This is super helpful, thanks for exposing your generatorit!

Maybe we should add the above example to the documentation? I ultimately have a need to to separate codecs and combined codecs in our prod workflow

When i went ahead and was going som throush some of the varios components i noticed that class name and looked here. I was going to try and use this skip_encryption=0|1 to generate the other manifests at first glance that seems like it might have been design for just such a the use case

@kqyang big thanks to you and all the folks contributing! Looking forward to replacing one of my vendors!

kqyang commented 4 years ago

@krzemienski Glad that you like the project!

Maybe we should add the above example to the documentation? I ultimately have a need to to separate codecs and combined codecs in our prod workflow

I agree that it should be documented. I'll see if I can find a time to do it. If you are interested, feel free to send us a pull request: https://github.com/google/shaka-packager/blob/master/docs/source/tutorials/dash.rst.

krzemienski commented 4 years ago

@kqyang I would be happy to contribute. I wrapped things up in a shell script that allows you make X dash manifest based on a what codecs and audio tracks youd like from the glob of .media_infos and ill include it in the PR and we can see if its something worth also adding for folks to use. Will make sometime to open the pr this weekend!

kqyang commented 4 years ago

@krzemienski SG. Thanks.