Our use case is a backend service that publishes a live audio stream 24/7 via MPEG-DASH, posting 10-second media segments numbered from the Unix epoch.
Source audio is a series of 10-second media segments in uncompressed .wav format. The tricky part here (as opposed to using ffmpeg for turn-key live streaming of a video source) is that I need to use ffmpeg once per .wav -> .m4s conversion.
While seemingly easy to concatenate an initializing .mp4 plus a series of .m4s segments into a playable stream, this only works if the segments have the correct series metadata. I need more details about precisely what that metadata might be. So far, I’ve figured out that ffmpeg accepts a -start_number
argument (if I run it in HLS mode, fine since I’m ignoring the ffmpeg-generated playlist file). Still, I haven’t figured out a tool or process to inspect the final .m4s file, understand precisely how a .m4s media segment metadata works in sequence, or how to “forge” a series of .m4s in this way.
The backend service ships MPEG-DASH files to static hosting. I upload the initializing .mp4 segment once, subsequently only uploading each new .m4s segment.
Also, the playlist .mpd is updated every segment to tell a newly arriving listener where to begin playback. The listener will pick up an initializing .mp4 file for the desired bitrate, followed by the current and following .m4s segments.
- My source material is a series of 10-second media segments in uncompressed .wav format.
- I’ll run ffmpeg once per each new media segment
- I’ve specified a segment size of 11 seconds to ensure that ffmpeg generates exactly one output .m4s segment for each source media segment.
ffmpeg
-i pelicans-1234.wav
-f hls
-ac 2
-c:a aac
-b:a 128k
-minrate 128k
-maxrate 128k
-start_number 1234
-hls_fmp4_init_filename pelicans-128k-IS.mp4
-hls_segment_filename pelicans-128k-%d.m4s
-hls_segment_type fmp4
-hls_time 11
temp.m3u8
This operation succeeds without error. The resulting .mp4 and .m4s files may be concatenated and played back. But, shipping the MPEG-DASH stream using this method fails on the client ned with errors (in VLC) like
mp4: Fragment sequence discontinuity detected 1 != 2