gpac icon indicating copy to clipboard operation
gpac copied to clipboard

Multibitrate MPEG-DASH failed to create

Open alex-rsk opened this issue 1 year ago • 4 comments

  • [x] I looked for a similar issue and couldn't find any.
  • [x] I tried with the latest version of GPAC. Installers available at https://gpac.io/downloads/gpac-nightly-builds/
  • [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...).

Greetings.

I continue my attempts to make Mpeg-dash stream with adaptive bitrate. It is related with issue 2868.

In order to achieve this, I'm trying to rescale with MP4Box on the fly.

MP4Box -dash 2000 \
 -dash-ctx /dev/shm/broadcast/context.txt -profile dashavc264:live \
--utcs="https://time.akamai.com/?iso&ms" \
-mpd-refresh 2  \ 
-dynamic \
-bs-switching merge \
 -segment-timeline -url-template \
 -insert-utc  \
-min-buffer 15 \
 -mpd-title "Test ABR" \
 -time-shift 30 \
/dev/shm/broadcast/input.mp4#video:dur=10:@ffsws:osize=160x120@enc:c=avc:b=100k:#Representation=Rep1@@ffsws:osize=320x240@enc:c=avc:b=200k:#Representation=Rep2 \
/dev/shm/broadcast/input.mp4#audio:dur=10  \
 -out /dev/shm/broadcast/manifest.mpd  

First run is successfull Second run brings errors and stream doesn't play after first segment.

Command /usr/local/bin/MP4Box -dash 2000 -dash-ctx /dev/shm/broadcast/context.txt -profile dashavc264:live --utcs="https://time.akamai.com/?iso&ms" -mpd-refresh 2 -dynamic -bs-switching merge -segment-timeline -url-template -insert-utc -min-buffer 15 -mpd-title "Luuv" -time-shift 30 /dev/shm/broadcast/input.mp4#video:dur=10:@ffsws:osize=160x120@enc:c=avc:b=100k:#Representation=Rep1@@ffsws:osize=320x240@enc:c=avc:b=200k:#Representation=Rep2 /dev/shm/broadcast/input.mp4#audio:dur=10 -out /dev/shm/broadcast/manifest.mpd  
[2024-06-13 10:33:16] local.DEBUG: 5: [Dasher] No template assigned, using $File$_dash$FS$$Time$
[FFSWS] Converting from 640x480@yuv420 to 160x120@yuv420                                                                              
[FFSWS] Setup rescaler from 640x480 fmt yuv420 to 160x120 fmt yuv420                                                                  
[FFSWS] Converting from 640x480@yuv420 to 320x240@yuv420                                                                              
[FFSWS] Setup rescaler from 640x480 fmt yuv420 to 320x240 fmt yuv420                                                                  
[FFSWS] Converting from 640x480@yuv420 to 160x120@yuv420                                                                              
[FFSWS] Setup rescaler from 640x480 fmt yuv420 to 160x120 fmt yuv420                                                                  
[FFSWS] Converting from 640x480@yuv420 to 320x240@yuv420                                                                              
[FFSWS] Setup rescaler from 640x480 fmt yuv420 to 320x240 fmt yuv420                                                                  
[Dasher] Synchronized clock to remote https://time.akamai.com/?iso&ms - UTC diff (local - remote) 7 ms                                
[AVC|H264] Possible Variable Frame Rate: VUI "fixed_frame_rate_flag" absent                                                           
[AVC|H264] Possible Variable Frame Rate: VUI "fixed_frame_rate_flag" absent                                                           
[Dasher] Input /dev/shm/broadcast/input.mp4: max audio duration 9928/1000 in the period is less than duration 10000/1000, clamping will happen                                                                                                                   
[Dasher] Input /dev/shm/broadcast/input.mp4: max audio duration 9928/1000 in the period is less than duration 10000/1000, clamping will happen                                                                                                                   
[Dasher] AS-1 Rep 1 segment 6 done 1325 ms before UTC due time                                                                        
[Dasher] updated period DID1 duration 11981 MPD time 11981                                                                            
[MPD] Generating MPD at time 2024-06-13T10:33:15.688Z                                                                                 
[Dasher] AS-1 Rep 1 segment 7 done 3319 ms before UTC due time                                                                        
[Dasher] updated period DID1 duration 13978 MPD time 13978                                                                            
[MPD] Generating MPD at time 2024-06-13T10:33:15.691Z                                                                                 
[Dasher] AS-1 Rep 1 segment 8 done 5318 ms before UTC due time                                                                        
[Dasher] updated period DID1 duration 15980 MPD time 15980                                                                            
[MPD] Generating MPD at time 2024-06-13T10:33:15.694Z                                                                                 
[Dasher] AS-1 Rep 1 segment 9 done 7312 ms before UTC due time                                                                        
[Dasher] updated period DID1 duration 17977 MPD time 17977                                                                            
[MPD] Generating MPD at time 2024-06-13T10:33:15.697Z                                                                                 
[Dasher] AS-1 Rep 1 segment 10 done 9332 ms before UTC due time                                                                       
[Dasher] updated period DID1 duration 19927 MPD time 1992700s (100.00 %) AS#2.2(V) done (6 segs)                                      
[MPD] Generating MPD at time 2024-06-13T10:33:15.701Z                                                                                 
[Dasher] updated period DID1 duration 19927 MPD time 1992700s (100.00 %) AS#2.2(V) done (6 segs) / MPD 10.80s 102 %                   
[MPD] Generating MPD at time 2024-06-13T10:33:15.708Z     
                                                                            
[Filter] dasher (idx 11) not responding properly: 100000 consecutive process with no packet discarded or sent, but 3 packets pending  
        discarding all inputs and notifying end of stream on all outputs                                                              
[MP4Mux] PID has no input packet and configuration not known after 10 retries, aborting initial timing sync                           
[MP4Mux] Unable to setup fragmentation for track ID 0: Bad Parameter                                                                  
Error DASHing file: Bad Parameter               

How I can make multiple bitrate versions another way?

alex-rsk avatar Jun 13 '24 10:06 alex-rsk

Could you post the video files associated with first run and second run ? I suspect their duration do not match the segment duration specified.

You can also try adding --force_flush to your command line.

jeanlf avatar Jun 13 '24 11:06 jeanlf

Could you post the video files associated with first run and second run ? I suspect their duration do not match the segment duration specified.

Sure

https://www.dropbox.com/scl/fo/lnja9qg6brspee7a627eh/ANoENOz5nAhQt_UWyxJOvuc?rlkey=97wc2cqoafl5gs8gihzbz7pbw&st=p7zddlmt&dl=0

Thank you very much. I'll try force-flush soon.

alex-rsk avatar Jun 13 '24 13:06 alex-rsk

Version with --dash=10000 and --force_flush is acting! Thank you, savior.

But what if I want to chop 10s segments to lesser fragments to decrease latency? Should I add i.e -frag 1000?

alex-rsk avatar Jun 13 '24 13:06 alex-rsk

Nope, -frag only controls fragments (moof+mdat), not segments.

I had to rework a bit more the dasher context for this use case, so --force_flush is being deprecated in favor of --sflush. For your use case, using --sflush=end will allow generating 2s segments but will not close period/loop at end .

Could you cross-check ?

jeanlf avatar Jun 20 '24 14:06 jeanlf

Thank you very much, missed your comment. I have problems with access to internet now, will check asap.

alex-rsk avatar Jul 02 '24 08:07 alex-rsk

Could you cross-check ?

Works like a charm on single bitrate stream. When there's multi-bitrate stream, it starting to place pieces of different quality during one 10s meta-segment. But this is mostly the player issue. Thank you again!

alex-rsk avatar Jul 02 '24 14:07 alex-rsk