gpac / gpac

GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery
https://gpac.io
GNU Lesser General Public License v2.1
2.61k stars 511 forks source link

MPEG_DASH manifest with audio track doesn't play in dash.js #2815

Closed alex-rsk closed 3 days ago

alex-rsk commented 1 month ago

Given: video fragments of equal length, prepared from some source stream by segmenting into 10s chunks. Example command of preparation:

ffmpeg  -loglevel  verbose -i <SOURCE_URL>  -c:v  libx264  -c:a  aac -preset veryfast -force_key_frames 'expr:gte(t,n_forced*2)'
-f  segment -segment_time 10  -reset_timestamps 1   -map 0  "/chunks/seg_%03d.mp4"

So we have seg_0001.mp4, seg_0002.mp4 etc. You can download prepared files from here: link

Goal:

Dash these segments sequentially, as the next segment becomes fully written and ready.

Example commands:

# First  copy seg_000[1,2,3...].mp4 to input mp4
# Then:
MP4Box  -dash 10000
        -dash-ctx ./stream/context.xml
        -profile dashavc264:live
        -mpd-refresh 20
        -dynamic
        -bs-switching no
        -segment-timeline
        -url-template       
        -time-shift -1
                input.mp4#video
        input.mp4#audio
        -out ./stream/stream.mpd

Estimated result: the dash manifest plays in dash.js player or reference dash-if player. When the next segment is adding to manifest, it is playing next. Obtained result: dash.js plays only first 10s fragment, and then hangs.

I tried:

Addendum: when I remove -dash-ctx, it plays with sound, but loops around the initial fragment, as expected. I have a vague feeling that there is a problem somewhere in keeping sound in dash-context. It is surely my musings and no more.

What helped else?

When I substitute to source the actual filename, instead of renaming it to "input.mp4", then, everything works. But, the stream.mpd and context.xml are constantly growing, because there are emerging new Period xml-entities. I've posted about it in the issue #2801

So, it would be cool if you fix that problem with live streaming with sound.

Cheers!

alex-rsk commented 3 weeks ago

It would be great at least to have a comment about confirmation or disproval of that bug from @jeanlf .

rbouqueau commented 3 weeks ago

Thanks again for reporting and documenting the issue. We're slower than usual for processing issues these days but it doesn't mean we don't welcome them nor don't plan to do our best to address them. Thanks for your patience.

alex-rsk commented 2 weeks ago

I wrote a simple script for reproduce. Before launch please download attached files (seg_000.mp4....seg_004.mp4) and run:

#!/bin/bash
if [ ! -d "stream" ]; then
  mkdir stream
fi 

for i in $(seq 0 4);                                                                                                                  
do
  cp "seg_00$i.mp4" input.mp4
  echo "Adding segment $i"
  MP4Box  -dash 10000 \
          -dash-ctx ./stream/context.xml \
          -profile dashavc264:live \
          -mpd-refresh 10 \
          -dynamic \
          -bs-switching no \
          -segment-timeline \
          -url-template \       
          -time-shift -1 \
                  input.mp4#video \
          input.mp4#audio \
          -out ./stream/stream.mpd
  sleep 9
done
jeanlf commented 3 days ago

Indeed, the second stream was not correctly reloaded , now fixed thanks for the report (and check #2801)