Bento4 icon indicating copy to clipboard operation
Bento4 copied to clipboard

Support for roles in files containing multiple audio stream.

Open smwhr opened this issue 8 years ago • 12 comments

Specify either via

--role-map 1:main,2:main,3:commentary,4:commentary

or

--role-map-file roles.json

with roles.json containing :

{"1":{"role":"main"}, "2":{"role":"main"}, "3":{"role":"commentary"}, "4":{"role":"commentary"}}

The output is compatible with DashJS player.

smwhr avatar Aug 18 '16 11:08 smwhr

There's already an (undocumented) interface for setting the roles: Using the --attributes command line option (which can be used once or more), you can set attributes for different parts of the presentation, including roles. Example: mp4dash --attributes video:role=main video.mp4

barbibulle avatar Aug 18 '16 21:08 barbibulle

Maybe I'm mistaken, but if I have 2 audio streams in my source file that have the same bitrate (±10%) and the same language (and obviously the same codec), they become undistinguishable because the key of the dict is

adaptation_set_name = ('audio', track.language, track.codec_family)

so AddDescriptor never gets to be applied to individual streams, only to a group of them.

And furthermore, despite having wildly different roles (one is commentary, one is the actual soundtrack)(and to complicate the matter, I have them in both english and french, and each in 2 qualities), they finish in the same Adaptation set at the end which is not the intended output.

What I want in the end is something along the lines of :

<MPD>
 <Period>
  <!-- video -->
  <AdaptationSet mimeType="video/mp4">
    <Representation bandwidth="228964"></Representation>
    <Representation bandwidth="113904"></Representation>
  </AdaptationSet>
  <!-- audio -->
  <AdaptationSet mimeType="video/mp4" lang="en" mimeType="audio/mp4">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
    <Representation audioSamplingRate="48000"></Representation>
    <Representation audioSamplingRate="16000"></Representation>
  </AdaptationSet>
  <AdaptationSet mimeType="video/mp4" lang="en" mimeType="audio/mp4">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="commentary"/>
    <Representation audioSamplingRate="48000"></Representation>
    <Representation audioSamplingRate="16000"></Representation>
  </AdaptationSet>
  <AdaptationSet mimeType="video/mp4" lang="fr" mimeType="audio/mp4">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
    <Representation audioSamplingRate="48000"></Representation>
    <Representation audioSamplingRate="16000"></Representation>
  </AdaptationSet>
  <AdaptationSet mimeType="video/mp4" lang="fr" mimeType="audio/mp4">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="commentary"/>
    <Representation audioSamplingRate="48000"></Representation>
    <Representation audioSamplingRate="16000"></Representation>
  </AdaptationSet>
 </Period>
</MPD>

smwhr avatar Aug 24 '16 08:08 smwhr

I see what you mean. I was planning on adding support for grouping tracks together (not just for audio, but for alternate video angles too), using a unified mechanism. That would handle this case of multiple versions (with different roles) of audio tracks with the same language. I should have that feature ready fairly soon.

barbibulle avatar Aug 24 '16 18:08 barbibulle

That would be great ! Let me know, I'll make the changes on my side.

smwhr avatar Aug 24 '16 19:08 smwhr

Hi @barbibulle, do you know if your universal grouping mechanism is still scheduled in a near future ? The same problem is arising in the mp4-hls.py script : same codec and language lead to only 1 alternate audio stream to be selected and actually exported in the final hls directory. I think it would be nice to have the same mechanism here.

If you're busy at the moment, to do hesitate to contact me and maybe we can discuss what you intended to do and I can implement it.

best and thanks for the great work and updates on the rest of the code.

smwhr avatar Aug 07 '17 17:08 smwhr

I see what you mean. I was planning on adding support for grouping tracks together (not just for audio, but for alternate video angles too), using a unified mechanism. That would handle this case of multiple versions (with different roles) of audio tracks with the same language. I should have that feature ready fairly soon.

Is this feature implemented? If yes, give an example please, I can not find (or understand) from the documentation.

st1ng2 avatar May 21 '20 18:05 st1ng2

I see what you mean. I was planning on adding support for grouping tracks together (not just for audio, but for alternate video angles too), using a unified mechanism. That would handle this case of multiple versions (with different roles) of audio tracks with the same language. I should have that feature ready fairly soon.

Is this feature implemented? If yes, give an example please, I can not find (or understand) from the documentation.

Yes, the current version allows you to specify labels on the audio sources, which can be used tp keep multiple tracks with the same language and codec and bitrate. Is that what you're looking for? I can give an example if that's the case.

barbibulle avatar May 22 '20 19:05 barbibulle

I see what you mean. I was planning on adding support for grouping tracks together (not just for audio, but for alternate video angles too), using a unified mechanism. That would handle this case of multiple versions (with different roles) of audio tracks with the same language. I should have that feature ready fairly soon.

Is this feature implemented? If yes, give an example please, I can not find (or understand) from the documentation.

Yes, the current version allows you to specify labels on the audio sources, which can be used tp keep multiple tracks with the same language and codec and bitrate. Is that what you're looking for? I can give an example if that's the case.

I am looking for command, that allows grouping of DASH/HLS audio for different quality videos (e.g. stereo for low quality video, surround for high quality video) If possible, please, give an example command.

st1ng2 avatar May 22 '20 19:05 st1ng2

Hi,

I also need this option for viewpoints. Can you publish a sample how to use it?

mp4dash --mpd-name=manifest.mpd --hls --attributes video:{urn:mpeg:dash:role:2011}viewpoint=vp1 ../tmp-video-1080.mp4 ../tmp-video-720.mp4 ../tmp-audio-en.mp4 ../tmp-audio-es.mp4 \[+format=webvtt,+language=de\]../de.vtt \[+format=webvtt,+language=en\]../en.vtt

With the solution above I only have one video adaptation set with a viewpoint declaration. But i need multiple video adaptation sets with different viewpoint declarations :) How can I do that?

Cheers Stephan

StephanGerbeth avatar Jun 12 '20 12:06 StephanGerbeth

I see what you mean. I was planning on adding support for grouping tracks together (not just for audio, but for alternate video angles too), using a unified mechanism. That would handle this case of multiple versions (with different roles) of audio tracks with the same language. I should have that feature ready fairly soon.

Is this feature implemented? If yes, give an example please, I can not find (or understand) from the documentation.

Yes, the current version allows you to specify labels on the audio sources, which can be used tp keep multiple tracks with the same language and codec and bitrate. Is that what you're looking for? I can give an example if that's the case.

@barbibulle could you provide an example for this case that you mentioned(multiple track with same language and specify label)

ai-93 avatar Jul 07 '21 06:07 ai-93

Can you provide an example?

AswinParanji avatar Feb 02 '22 13:02 AswinParanji