Search code examples
ffmpegprefixsubdirectoryplaylistsegment

ffmpeg: How to include dynamic path in m3u8 playlist? (Playlist and segments are in different directories.)


I have a live webcam stream, I use ffmpeg to cut it to 10-second segments, stream it live, and store the segments in a day/hour directory structure.

ffmpeg.exe [input]
-f segment
-strftime 1
-segment_format mpegts
-segment_time 10
-segment_list_size 6
-segment_list "D:\cams\cam1\live.m3u8"
-segment_list_type m3u8
"D:\cams\cam1\%a\%H\%M%S.ts"

So my "live.m3u8" and my segments are in different directories (the segments are in a subdirectory). By default when ffmpeg generates the m3u8 list it only adds the filename: instead of Fri/12/1234.ts the filename line is only 1234.ts, so it's obviously not working.

There is an option segment_list_entry_prefix to add the path as a prefix, but my prefix is dynamic (%a/%H/). For some reason, the dynamic arguments are not working: instead of Fri/12/1234.ts the playlist has %a/%H/1234.ts.

Is it an ffmpeg bug, or something's missing from my command? How can it be fixed?


Solution

  • The routine that writes out the list entry extracts the basename of each segment, so it can't be done at present. Try the HLS muxer.