[FFmpeg-user] Struggling to convert mp4 to HLS with Constant Bit Rate and Constant Frame Rate

John Harlow johnrharlow at mac.com
Fri Oct 30 21:15:38 EET 2020

I am trying to re-encode a set of mp4 files (a mix of 1080p and 720p, all at 30FPS) to HLS with constant bit and frame rates. I also need a 29.97 frame rate, CABAC/2 and fixed 6.006 sec ts segments.

I have experimented with a lot of options, so the ffmpeg string I am using is probably both inefficient and hideous AND I can’t achieve the desired result.

I’m trying to use max rate and min rate to hold the bitrate at 2M and fps=fps=29.97 to make the frame rate constant.

Here is my current ffmpeg string:

/usr/bin/ffmpeg -i "$SOURCE" \
-profile:v high -level 3.1 -s 1280x720 -filter:v fps=fps=29.97 \
-strict -2 -c:a aac -c:v libx264 -g 60 -keyint_min 60 -force_key_frames "expr:gte(t,n_forced*2)" \
-f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.06 -segment_time_delta 0.1 \
-b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 3M \
-ar 48000 -start_number 0 \
-hls_time 6 -hls_list_size 0 -f hls \
-hls_base_url "$BASEURL" \
-hls_segment_filename "video%04d.ts" \
-strict -2 -threads 8 “video.m3u8"

I am running this on centos 7 and my ffmpeg version is 3.4.7.

Any advice on how to clean this up and achieve the desired results would be greatly appreciated.


More information about the ffmpeg-user mailing list