<p>a colleague figured it out (for a 20 second input video):</p>
<pre><code>ffmpeg -i input.mp4 -map 0 -c copy -f ssegment -segment_list playlist.m3u8 -segment_times 2,12,22 -break_non_keyframes 1 out%03d.ts
</code></pre>
<p>if used in a program then segment_times needs to be somehow generated with regards to media length - for instance it won't be 2,12,22 if your media is 60 seconds long and you want 20 second chunks (after the first 2 second one), it will be 2,22,42,62</p>

CC BY-SA 4.0
2024-08-20T22:45:48.573Z
2024-08-20T22:45:48.573Z
apes-together-strong
<p>Source video: h264 mp4, 45 seconds, 30 fps, keyint 30, min keyint 16</p>
<p>I am trying to create an m3u8 playlist where the first chunk is smaller (2 seconds) and the rest are 10 seconds.</p>
<p>when using this command:</p>
<pre><code>ffmpeg.exe -i test4_c.mp4 -codec copy -bsf:v h264_mp4toannexb -start_number 0 -hls_init_time 2 -hls_time 10 -f hls -hls_list_size 0 test4_hls.m3u8
</code></pre>
<p>result is 4 10 second ts chunks</p>
<p>when using this command:</p>
<pre><code>ffmpeg.exe -i test4_c.mp4 -codec copy -bsf:v h264_mp4toannexb -start_number 0 -hls_init_time 2 -hls_time 10 -f hls -hls_list_size 100 test4_hls.m3u8
</code></pre>
<p>result is 23 2 second ts chunks</p>
<p>what's the issue here?</p>
<p>I have already read this:
<a href="https://stackoverflow.com/questions/43489097/ffmpeg-hls-init-time-hls-time-not-working-together">https://stackoverflow.com/questions/43489097/ffmpeg-hls-init-time-hls-time-not-working-together</a>
and it doesn't work</p>

<ffmpeg>
ffmpeg: -hls_time and -hls_init_time not working
apes-together-strong
# ffmpeg: -hls_time and -hls_init_time not working

(Asked by: username_0 on 2024-08-19)

Source video: h264 mp4, 45 seconds, 30 fps, keyint 30, min keyint 16
I am trying to create an m3u8 playlist where the first chunk is smaller (2 seconds) and the rest are 10 seconds.
when using this command:
ffmpeg.exe -i test4_c.mp4 -codec copy -bsf:v h264_mp4toannexb -start_number 0 -hls_init_time 2 -hls_time 10 -f hls -hls_list_size 0 test4_hls.m3u8

result is 4 10 second ts chunks
when using this command:
ffmpeg.exe -i test4_c.mp4 -codec copy -bsf:v h264_mp4toannexb -start_number 0 -hls_init_time 2 -hls_time 10 -f hls -hls_list_size 100 test4_hls.m3u8

result is 23 2 second ts chunks
what's the issue here?
I have already read this:
https://stackoverflow.com/questions/43489097/ffmpeg-hls-init-time-hls-time-not-working-together
and it doesn't work

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_0 on 2024-08-20. Score: 0

a colleague figured it out (for a 20 second input video):
ffmpeg -i input.mp4 -map 0 -c copy -f ssegment -segment_list playlist.m3u8 -segment_times 2,12,22 -break_non_keyframes 1 out%03d.ts

if used in a program then segment_times needs to be somehow generated with regards to media length - for instance it won't be 2,12,22 if your media is 60 seconds long and you want 20 second chunks (after the first 2 second one), it will be 2,22,42,62


---

