mygov
mygov

Reputation: 150

How can I create a master m3u8 playlist for my encrypted sub-playlists (created with ffmpeg)?

If I create three outputs with the following ffmpeg command for an encrypted HLS stream, how I am able to create a master.m3u8 variant playlist (with correct BANDWIDTH)?

./ffmpeg -re -i Test_1080p.mp4 \
     -c:a aac -b:a 128k -c:v libx264 -s 1920x1080 -g 48 -keyint_min 48  -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 7800k -maxrate 8600k -bufsize 7800k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file enc.keyinfo ./1080p/index.m3u8 \
     -c:a aac -b:a 128k -c:v libx264 -s 1280x720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 4500k -maxrate 5000k -bufsize 4500k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file enc.keyinfo ./720p/index.m3u8 \
    -c:a aac -b:a 64k -c:v libx264 -s 640x360 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 730k -maxrate 800k -bufsize 730k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file enc.keyinfo ./360p/index.m3u8

Here is some example I found, but I think the BANDWIDTH-Value is not correct for my output files. How do I calculate the correct bandwidth?

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=150000,RESOLUTION=640x360
http://example.com/360p/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=240000,RESOLUTION=1280x720
http://example.com/720p/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=640000,RESOLUTION=1920x1080
http://example.com/1080p/index.m3u8

The variantplaylistcreator-tool from Apple will not work in this case because I need .plist files, ffmpeg does not generate these files.

I think ffmpeg is not able to create a master.m3u8 playlist for the generated output files..

Upvotes: 2

Views: 5353

Answers (1)

aergistal
aergistal

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.


FFmpeg doesn't create the master playlist but you can do it manually like in the example.

The BANDWIDTH attribute represents the peak bitrate of the variant. For multiplexed streams like yours the value is the peak audio bitrate + peak video bitrate + mux overhead (including any encryption padding). If you have separate video/audio you must take into account the highest-bitrate combination of renditions.

The muxing overhead is shown when the ffmpeg command ends but only if you have a single output. Once you choose the encoding parameters you can run some tests and make an educated guess based on the results.

One thing to keep in mind is that the measured value must be within 10% of the declared bandwidth for VOD and respectively within 25% for 1 hour of live content based on the Apple guidelines.

Upvotes: 1

Related Questions