<p>I have a multi resolution m3u8 file, created from 1080p60 source file. Resolutions lower than 720p are converted to 30fps, while 720p+ stay at 60fps.</p>
<p>The problem is that the first segment is broken between 30 and 60fps renditions, causing an overlap, which is detected by hls.js as a gap between segments for some reason.</p>
<p>I have checked the segment files manually and it looks like they are fine, except for single audio frame missing between them, 60fps one has 187 'frames', while 30fps one has 186 'frames'.</p>
<p>Videos are segmented in <strong>separate</strong> ffmpeg runs, but using the same settings, differing only in FPS, resolution and bitrate. Source file is always the same.</p>
<p>Is there a way to fix this?</p>
<p>Thanks!</p>
<p><a href="https://i.sstatic.net/zsxY0.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zsxY0.jpg" alt="first segment gap" /></a>
<a href="https://i.sstatic.net/XATnQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XATnQ.png" alt="segment info" /></a></p>

CC BY-SA 4.0
2023-09-07T11:55:25.757Z
What are your encoding commands?
Gyan
CC BY-SA 4.0
2023-09-07T12:07:06.920Z
@Gyan it's

`-async 30 -fps_mode cfr -vf \"scale=640:-2,framerate=fps=30\" -ac 2 -preset faster -crf 23 -b:a 128k -maxrate 1160k -bufsize 1600k -force_key_frames expr:if(isnan(prev_forced_n),1,eq(n,prev_forced_n+30)) -g 30 -keyint_min 30 -sc_threshold 0 -hls_time 4 -hls_list_size 0 -hls_playlist_type vod -hls_flags independent_segments+discont_start -max_muxing_queue_size 9999 -profile:v main -pix_fmt yuv420p -fflags +genpts -r 30` - it's the same for 60fps, just with different resolution and 30 gets replaced by 60
drajvver
<ffmpeg><hls>
First HLS segment overlapping when renditions have different framerates
drajvver
# First HLS segment overlapping when renditions have different framerates

(Asked by: username_0 on 2023-09-07)

I have a multi resolution m3u8 file, created from 1080p60 source file. Resolutions lower than 720p are converted to 30fps, while 720p+ stay at 60fps.

The problem is that the first segment is broken between 30 and 60fps renditions, causing an overlap, which is detected by hls.js as a gap between segments for some reason.

I have checked the segment files manually and it looks like they are fine, except for single audio frame missing between them, 60fps one has 187 'frames', while 30fps one has 186 'frames'.

Videos are segmented in **separate** ffmpeg runs, but using the same settings, differing only in FPS, resolution and bitrate. Source file is always the same.

Is there a way to fix this?

Thanks!

[![first segment gap](https://i.sstatic.net/zsxY0.jpg)](https://i.sstatic.net/zsxY0.jpg)
[![segment info](https://i.sstatic.net/XATnQ.png)](https://i.sstatic.net/XATnQ.png)

**Tags:** ffmpeg, hls

> **Comments:**
> **username_1**: What are your encoding commands?  
> **username_0**: @username_1 it's  `-async 30 -fps_mode cfr -vf \"scale=640:-2,framerate=fps=30\" -ac 2 -preset faster -crf 23 -b:a 128k -maxrate 1160k -bufsize 1600k -force_key_frames expr:if(isnan(prev_forced_n),1,eq(n,prev_forced_n+30)) -g 30 -keyint_min 30 -sc_threshold 0 -hls_time 4 -hls_list_size 0 -hls_playlist_type vod -hls_flags independent_segments+discont_start -max_muxing_queue_size 9999 -profile:v main -pix_fmt yuv420p -fflags +genpts -r 30` - it's the same for 60fps, just with different resolution and 30 gets replaced by 60  

---

## 0 answers

