8

I'm attempting to take a 5-minute video file and produce a single-file HTTP Live Stream playlist and .ts file. The playlist file format can support byte-ranges instead of separate files as of iOS 5, which is a fine target for my use cases. But, when I run my ffmpeg command, the first entry in the resulting .m3u8 playlist does not start at (or even near) byte 0.

For example:

ffmpeg -i input -hls_flags single_file out.m3u8

Produces a playlist like so:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:63
#EXTINF:1.376367,
#EXT-X-BYTERANGE:568324@63107840
out.ts
#EXTINF:1.334667,
#EXT-X-BYTERANGE:235564@63676164
out.ts
#EXTINF:1.918589,
#EXT-X-BYTERANGE:343288@63911728
out.ts
#EXTINF:10.427078,
#EXT-X-BYTERANGE:3311996@64255016
out.ts
#EXTINF:5.672333,
#EXT-X-BYTERANGE:52828@67567012
out.ts
#EXT-X-ENDLIST

Note that the first EXT-X-BYTERANGE entry is not @0 -- it's about 63 MB into the 68 MB .ts file. Indeed, when loading the playlist into a <video> tag and opening the HTML with Safari, video playback starts about 20 seconds from the end of the input video, not at 0, and there's no way to scrub any earlier.

Why has ffmpeg produced a playlist that doesn't include all of the video? When I watch the .ts file produced alongside the playlist, all the video content is present.

I see this on recent ffmpeg static builds under Linux, as well as a Homebrew-built version of ffmpeg 2.7.1 under OS X.

Collin Allen
  • 1,245

1 Answers1

10

After reading the HLS documentation again, I finally noticed this option:

hls_list_size size

Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.

Sure enough, in my initial question, there are 5 EXT-X-BYTERANGE entries from the end of the video, consistent with the stated default value. Setting hls_list_size to 0 as indicated does in fact ensure the video starts at the beginning and includes all the expected byte ranges.

Collin Allen
  • 1,245