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.76k stars 532 forks source link

MP4Box/dasher Feature Request (?): Allow passing -base-url and/or :BaseURL= through to HLS playlists as absolute paths #2199

Closed vt-idiot closed 2 years ago

vt-idiot commented 2 years ago

I hope that makes sense. Unless I am missing something, there appears to be no way to generate an HLS M3U8 with absolute paths. It definitely shouldn't be a default option (Apple recommends relative paths but allows for both), yet having a way to enable it for edge cases that require it would be nice.

mp4box -dash 10000 file.mp4 -segment-name "$File$_dash$FS$$Number%02d$" -frag-rap -base-url "https://some.url/some/folder/" -mpd-info-url "https://files.catbox.moe/om3tcw.webm" -mpd-title "Mikoboat (2020)" -mem-frags -out Mikoboat.mpd:dual

The output .mpd does have the base-URL as expected. The m3u8 always just has segment names.

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="file_dashinit.mp4"
#EXTINF:10.00,
file_dash01.m4s
#EXTINF:10.00,
file_dash02.m4s
#EXTINF:10.00,
file_dash03.m4s

Whereas it would be nice to output m3u8 directly (without batch Find/Replace-ing in a text editor) that looked like:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="https://some.url/some/folder/file_dashinit.mp4"
#EXTINF:10.00,
https://some.url/some/folder/file_dash01.m4s
#EXTINF:10.00,
https://some.url/some/folder/file_dash02.m4s
#EXTINF:10.00,
https://some.url/some/folder/file_dash03.m4s

I tried adding -base-url again after the -out filename, but that changed nothing. It looks like there's already an option for doing the reverse: forcing URLs to be included when generating an MPD from HLS?

-url-template-sim: use SegmentTemplate simulation while converting HLS to MPD

Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

Detailed guidelines: http://gpac.io/2013/07/16/how-to-file-a-bug-properly/

jeanlf commented 2 years ago

Now on master, dasher option hls_absu:

MP4Box -dash 10000 file.mp4 -segment-name "$File$_dash$FS$$Number%02d$" -frag-rap \
-base-url "https://some.url/some/folder/" -mpd-info-url "https://files.catbox.moe/om3tcw.webm" \
-mpd-title "Mikoboat (2020)" -mem-frags -out Mikoboat.mpd:dual \
--hls_absu=both

This does not impact the key URI if any, which is always copied as is.

vt-idiot commented 2 years ago

Working beautifully and as expected in MP4Box - GPAC version 2.1-DEV-rev173-g82dd6d2b-master. Thank you!