Since, Apple has announced the support for fragmented MP4, Is it possible to create both DASH manifest (.mpd) and HLS manifest (.m3u8) for the same set of segments ( for separate audio and video). How to do it?
The DASH manifest file is known as a Media Presentation Description, or MPD. It is XML-based and contains all the information necessary for the client to download and present a given piece of content.
The MPEG-DASH standard requires that initialization segments (in your case the mp4 file) contain no data. This is because when switching the player might use several times the initialization segment. You can open it in a player but it does not contain any media.
The Media Presentation Description (MPD) is a document that contains metadata required by a DASH Client to construct appropriate HTTP-URLs to access Segments and to provide the streaming service to the user.
The following example shows an HLS media manifest that AWS Elemental MediaTailor received by HLS from the content origin. This example uses EXT-X-CUE-OUT and EXT-X-CUE-IN tags to describe ad avail opportunities.
MPEG DASH is a platform and browser-agnostic video streaming protocol. There are plenty of freely-available online players, and more and more browsers include native DASH support, eliminating the need for external players or plugins.
Also used by very large platforms such as Youtube or Netflix, DASH is quite similar to HLS in its general structure: sequenced files listed in a file posing as a playlist. DASH, in addition to being ISO-standardized, has several features not found in other similar technologies, at the price of a slightly higher complexity.
Fundamental to the MPEG-DASH protocol is the manifest or MPD (Media Presentation Description) that is created when the media is packaged and prepared for transmission via DASH. In this edition of the guide to MPEG-DASH, we dig into the DASH Media Presentation Description (MPD), as defined in ISO/IEC 23009-1.
I don't know if it's possible with ffmpeg, but shaka-packager is able to do just this. Following command will output MP4 segments as well as HLS and DASH manifests, reusing MP4 segments for both (not sure if you can use existing MP4 segments though, you might have to mux them back into a single mp4 per video stream first):
# HLS + DASH
packager \
'in=h264_baseline_360p_720.mp4,stream=audio,init_segment=audio_init.mp4,segment_template=audio_$Number$.m4s,playlist_name=audio.m3u8,hls_group_id=audio,hls_name=ENGLISH' \
'in=h264_baseline_360p_720.mp4,stream=video,init_segment=h264_360p_init.mp4,segment_template=h264_360p_$Number$.m4s,playlist_name=h264_360p.m3u8' \
'in=h264_main_480p_1400.mp4,stream=video,init_segment=h264_480p_init.mp4,segment_template=h264_480p_$Number$.m4s,playlist_name=h264_480p.m3u8' \
'in=h264_high_720p_2400.mp4,stream=video,init_segment=h264_720p_init.mp4,segment_template=h264_720p_$Number$.m4s,playlist_name=h264_720p.m3u8' \
--hls_master_playlist_output h264_master.m3u8 \
--mpd_output h264.mpd \
--base_urls https://example.org/ \
--hls_base_url https://example.org/ \
--generate_static_mpd
Be aware that, at the time of this writing, you need to use the master branch code (or the google/shaka-packager:latest docker image), as the newest release 1.6.2 will just exit with Cannot output both MPD and HLS.
Although I never used it so far, Bento4 is another tool which is able to package DASH and HLS in a single run:
mp4-dash.py | grep hls
--hls Output HLS playlists in addition to MPEG DASH
--hls-key-url=<url> HLS key URL (default: key.bin)
--hls-master-playlist-name=<filename>
--hls-media-playlist-name=<filename>
--hls-iframes-playlist-name=<filename>
I have also a experimental GPAC/MP4Box branch on github doing this:
https://github.com/DerouineauNicolas/gpac/tree/m3u8_mpd_rext
So far, expected use is the following:
MP4Box -dash 1000 $OUT_DIR/file.mp4#video $OUT_DIR/file.mp4#audio -m3u8-from-mpd $OUT_DIR/hls.m3u8 -segment-name test-$RepresentationID$-$Number%d$ -out $OUT_DIR/file.mpd
where -m3u8-from-mpd is the master playlist name. Playlists m3u8 files are generated in the same directory than the master playlist.
Feedbacks are welcome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With