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
2.01k stars 511 forks source link

Is it possible to add a new caption/audio without repackage everything? #719

Closed night91 closed 4 years ago

night91 commented 4 years ago

Hello Shaka team,

I wonder if is posible to add a new caption or audio (probably a new language) without having to repackage again everything in order to save space. This means you have the manifest with segments, but not longer the base files, you get a new caption and the manifest is refreshed with this new caption. So you would not need to have all different video bitrates stored always (or having to transcode them again.)

Thank you in advance!

kqyang commented 4 years ago

@night91 For VOD, yes, you can use mpd_generator. See examples here: https://github.com/google/shaka-packager/issues/709#issuecomment-583972746.

Does that work for you?

night91 commented 4 years ago

@kqyang I see this, you can generate the "data" for each stream and combine them. Then if a new one is coming, you just add it to the mpd_generator? Does this works also with HLS?

I see it does not work with with segment_template. Although I am interested in VOD. Will it be able to download the video in fragments, when using shaka player?

packager \
  'in=/media/v.mp4,stream=video,output=/media/video.mp4' \
 --output_media_info

packager \
  'in=/media/a.m4a,stream=audio,output=/media/audio.mp4' \
 --output_media_info

mpd_generator --input="video.mp4.media_info,audio.mp4.media_info" --output=all_streams.mpd

I am getting something weird. After get the video.mp4.media_info with the video.mp4(fragmeted). Shaka player in Chrome, does not play the video. It just download some fragments, 2 or 3 and stops, and never loads.

Even when I trie to download the video normally like in a web server, it just download 800b.(1 fragment?)

What I am missing?

kqyang commented 4 years ago

@night91

Then if a new one is coming, you just add it to the mpd_generator?

Correct.

Does this works also with HLS?

No. It does not work with HLS right now.

Will it be able to download the video in fragments, when using shaka player?

Yes.

Can you share the mpd? It looks like url problems to me? Did you generate the mpd and then copy the mpd to the web directory only?

night91 commented 4 years ago

@kqyang The the 2 files are in the same directory, all_streams.mpd and video.mp4.

Still do not understand why using the webserver i can download correctly the base v.mp4, but can't download(video.mp4) the one generated after the next code. It ways in the network tab from Chome, cancelled.

packager \
  'in=v.mp4,stream=video,output=video.mp4' \
 --output_media_info

mpd_generator --input="video.mp4.media_info" --output=all_streams.mpd
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version c257113-release-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT103S">
  <Period id="0">
    <AdaptationSet id="0" contentType="video" width="1920" height="1080" frameRate="12288/512" par="16:9">
      <Representation id="0" bandwidth="1503115" codecs="avc1.640032" mimeType="video/mp4" sar="2001:2000">
        <BaseURL>video.mp4</BaseURL>
        <SegmentBase indexRange="877-1124" timescale="12288">
          <Initialization range="0-876"/>
        </SegmentBase>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="1" contentType="audio">
      <Representation id="1" bandwidth="130905" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <BaseURL>audio.m4a</BaseURL>
        <SegmentBase indexRange="815-1050" timescale="44100">
          <Initialization range="0-814"/>
        </SegmentBase>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
kqyang commented 4 years ago

@night91 It looks correct to me. Could it be a problem in your web server configuration? Does the mpd work if you generate it directly with packager (without going through mpd_generator)?

night91 commented 4 years ago

@kqyang Yes, I am using the Docker release. With the next one, I can see my video normally in shaka player.

packager --segment_duration 2 \
  'in=/media/v.mp4,stream=video,init_segment=video/init.mp4,segment_template=video/$Number$.m4s' \
  'in=/media/a.m4a,stream=audio,init_segment=audio/init.m4a,segment_template=audio/$Number$.m4s' \
   --generate_static_mpd --mpd_output /media/example.mpd 
night91 commented 4 years ago

@kqyang is weird, look and the video.mp4 info (the one that don't download)

Comparing with other that works fine we can see the duration is 0, besides some changes in minor_version, compatible_brand. So for some reason the file generated after --output_media_info, is getting a duration of 0. Any guess?

File:
  major brand:      isom
  minor version:    200
  compatible brand: isom
  compatible brand: iso2
  compatible brand: avc1
  compatible brand: mp41
  compatible brand: iso5
  fast start:       yes

Movie:
  duration:   103000 ms
...
File:
  major brand:      isom
  minor version:    0
  compatible brand: iso8
  compatible brand: mp41
  compatible brand: dash
  compatible brand: avc1
  compatible brand: cmfc
  fast start:       yes

Movie:
  duration:   0 ms
...
night91 commented 4 years ago

@kqyang what I want to achieve(for VOD). Generate a streaming with ex: 5 adaptive bitrates, 1 audio output and 1 caption. But adding a new audio or caption, is expensive as I have to have all the transcoded files + the files associated to the dash package

kqyang commented 4 years ago

So for some reason the file generated after --output_media_info, is getting a duration of 0. Any guess?

That is expected for fragmented mp4. You should see something similar in the stream generated directly by packager too.

night91 commented 4 years ago

@kqyang it was the web server. I was using ruby -run -e httpd . -p 8080 to serve static content (the html + js was hosting the shaka player). but the python server make it run fine python3 -m http.server.

Any guess to do similar as mpd_generator for HLS, but dash probably won't be enough for IOS. Any proven IOS player that support dash?

kqyang commented 4 years ago

@night91

Any guess to do similar as mpd_generator for HLS, but dash probably won't be enough for IOS.

Feel free to file a feature request for HLS support.

We had a plan to support HLS, but we don't have resource to work on that right now. If you are interested in helping us implement it, I'll be happy to provide pointers.

Any proven IOS player that support dash?

I think Shaka Player supports dash in iOS for non DRM contents. @joeyparrish Correct me if I am wrong.

night91 commented 4 years ago

@kqyang following with mpd_generator limitations, there wont be a way to package several audio and subtitles as just generate al most 3 adaptation sets (video, audio, captions)?

joeyparrish commented 4 years ago

I think Shaka Player supports dash in iOS for non DRM contents. @joeyparrish Correct me if I am wrong.

Sorry, it's not that simple. Shaka Player can only support DASH on platforms with MediaSource Extensions. That is true of iOS 13+ on iPad only, but not any other iOS version or device. On iPhone or iPod or iOS < 13, we can only use Apple's native HLS implementation.

But we do delegate to native HLS on iOS browsers as a convenience feature.

kqyang commented 4 years ago

@joeyparrish I see. Thanks!

@night91

following with mpd_generator limitations, there wont be a way to package several audio and subtitles as just generate al most 3 adaptation sets (video, audio, captions)

There is no such limitation. You can package multiple audio and subtitles. Packager will create additional adaptation sets as needed. For example, if you add two audio with different codecs, two audio adaptation sets are created; otherwise if the two audio are using the same codec, only one audio adaptation set is created.

shaka-bot commented 4 years ago

@night91 Does this answer all your questions? Can we close the issue?

shaka-bot commented 4 years ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, you can ask us to reopen or have the bot reopen it by including @shaka-bot reopen in a comment.