Reputation: 110083
I am trying to create an HLS playlist with multiple audio streams. I have the following files:
- videoHD.mp4
- videoSD.mp4
- audioEN.mp4
- audioFR.mp4
- audioIT.mp4
How would I transmux these all together in an ffmpeg
command to create an HLS
playlist?
Upvotes: 2
Views: 8039
Reputation: 31209
Update January 2018
You can now create master playlists directly with FFmpeg using master_pl_name
and var_stream_map
. See the documentation.
According to the Apple docs you don't mux them all together and you can't use a single HLS playlist.
You need playlists for each video and each audio track (eg: hd/playlist.m3u8
, sd/playlist.m3u8
, en/playlist.m3u8
etc.) and a master playlist to link them all together. The master playlist controls the playback.
Here's an example with two video qualities and three audio tracks from the docs:
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="eng",NAME="English",AUTOSELECT=YES, \
DEFAULT=YES,URI="eng/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="fre",NAME="Français",AUTOSELECT=YES, \
DEFAULT=NO,URI="fre/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="sp",NAME="Espanol",AUTOSELECT=YES, \
DEFAULT=NO,URI="sp/prog_index.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=195023,CODECS="avc1.42e00a,mp4a.40.2",AUDIO="audio"
lo/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=591680,CODECS="avc1.42e01e,mp4a.40.2",AUDIO="audio"
hi/prog_index.m3u8
ffmpeg
didn't support variant playlists the last time I checked so you need to create each alternate playlist individually and manually create the master playlist.
Of course for all this to work the individual streams must be aligned or you'll have a lot of synchronization issues. You can try using ffmpeg
with multiple I/O:
ffmpeg -i input1 -i input2 \
-map … -acodec … -vcodec … output1 \
-map … -acodec … -vcodec … output2 \
-map … -acodec … -vcodec … output3
each output being of type HLS
.
Sources:
FFmpeg - Creating Multiple Outputs
Upvotes: 6