Repository navigation
HLS Master Playlist
The hls muxer is upstream FFmpeg. This build patches it so that the master playlist it writes meets Apple's HLS rules. The patch adds playlist attributes and four new keys for -var_stream_map.
Since: v1.0.39.
One video variant and one audio rendition, with the new keys:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f hls -hls_time 3 \
-master_pl_name master.m3u8 -hls_flags independent_segments \
-var_stream_map "v:0,agroup:aud,name:video a:0,agroup:aud,name:audio,aname:English%205.1,language:eng,default:yes,autoselect:yes,characteristics:public.accessibility.describes-video" \
out/v%v.m3u8The master playlist of this run on v1.0.47 (the lines were not changed):
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",NAME="English 5.1",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="eng",CHARACTERISTICS="public.accessibility.describes-video",CHANNELS="1",URI="vaudio.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=63418,AVERAGE-BANDWIDTH=63418,RESOLUTION=320x240,FRAME-RATE=24.000,CODECS="avc1.f4000d,mp4a.40.2",VIDEO-RANGE=SDR,AUDIO="aud",CLOSED-CAPTIONS=NONE
vvideo.m3u8
| What | Behaviour |
|---|---|
FRAME-RATE |
Written on each #EXT-X-STREAM-INF, always with three decimals (24.000). |
VIDEO-RANGE |
PQ for SMPTE ST 2084, HLG for ARIB STD-B67, SDR for everything else. It is taken from the stream's transfer characteristic. |
#EXT-X-INDEPENDENT-SEGMENTS |
Written in the master playlist when -hls_flags independent_segments is set. |
CLOSED-CAPTIONS=NONE |
Written on every variant when you give no -cc_stream_map, as Apple requires. |
FORCED=YES or FORCED=NO
|
Always written on subtitle renditions. |
AUTOSELECT |
AUTOSELECT=YES is implied for DEFAULT=YES and FORCED=YES renditions. |
| Group names | The agroup: value is used as given. Upstream added a group_ prefix. |
ffmpeg -h muxer=hls lists no new muxer option for this. The new parts are keys inside the -var_stream_map string.
| Key | What it does |
|---|---|
aname: |
The NAME of the audio rendition in #EXT-X-MEDIA. The map is split on spaces, so write a space as %20: aname:English%205.1. |
autoselect: |
yes or 1 sets AUTOSELECT=YES. no or 0 sets NO. |
sforced: |
yes or 1 marks the subtitle rendition FORCED=YES. |
characteristics: |
The CHARACTERISTICS string, for example public.accessibility.describes-video. %XX escapes are decoded. Use %2C for the comma between several values. |
The other keys, such as agroup:, sgroup:, ccgroup:, name:, sname:, language: and default:, are upstream keys.
| What | Behaviour |
|---|---|
hvc1 tag |
Apple needs the hvc1 sample entry for HEVC. Without it the CODECS attribute is dropped. The muxer now sets the tag itself and logs a warning. Use -tag:v hvc1 to silence the warning. |
CODECS from hvcC
|
The HEVC codec string is built from the hvcC data, so stream copies from MP4 and MOV files get a CODECS string too. |
Missing CODECS
|
If a CODECS attribute cannot be built, the muxer says so with a loud warning. |
The FRAME-RATE, VIDEO-RANGE, AUTOSELECT, CHARACTERISTICS, CLOSED-CAPTIONS=NONE, INDEPENDENT-SEGMENTS and aname: rows were checked in the run above. The HEVC rows and sforced: follow the source (scripts/includes/hlsenc.c, codecstring.c). They were not run in this documentation pass.
These are the upstream hls options this feature works with. The table is from ffmpeg -h muxer=hls of v1.0.47.
| Option | Type | Default | What it does |
|---|---|---|---|
master_pl_name |
string | none | Creates the master playlist with this name. |
master_pl_publish_rate |
int | 0 |
Publishes the master playlist every this many segment intervals. |
var_stream_map |
string | none | Groups streams into variants and renditions. Holds the keys above. |
cc_stream_map |
string | none | Closed-caption map. Without it, variants get CLOSED-CAPTIONS=NONE. |
hls_flags |
flags | 0 |
independent_segments is the flag the patch acts on. |
Four upstream files are replaced as a whole: hlsenc.c, hlsplaylist.c, hlsplaylist.h and codecstring.c. The build checks that each upstream file has the exact digest the copy was made from. If FFmpeg's own file is different, the build stops. That check exists because FFmpeg 9.0.2 fixed two buffer overruns in hlsenc.c, and a copy based on 9.0 would have undone them. The DASH muxer's call site is adapted to the changed function.
The patched muxer is in every platform archive.
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors