[FFmpeg-user] Generating HLS chunks on demand

Vincent Deconinck vdeconinck at gmail.com
Fri Jan 20 18:44:36 EET 2023


Hi,
I have thousands of files that I would like to serve as HLS streams to a
very small number of users (3-5), without having to process them all
upfront. So I'm looking for a way to generate single HLS chunks (as opposed
to a full HLS package) only when they are requested.
My problem is the resulting stream is choppy and basically unusable.
Here are the commands I'm using::

ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -ss 0
-t 4 -f mpegts cache\sample-0.ts
ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -ss 4
-t 4 -f mpegts cache\sample-1.ts
ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -ss 8
-t 4 -f mpegts cache\sample-2.ts
ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -ss 12
-t 4 -f mpegts cache\sample-3.ts
ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -ss 16
-t 4 -f mpegts cache\sample-4.ts

The m3u8 file is :

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:4.000000,
sample-0.ts
#EXTINF:4.000000,
sample-1.ts
#EXTINF:4,000000,
sample-2.ts
#EXTINF:4,000000,
sample-3.ts
#EXTINF:4,000000,
sample-4.ts
#EXT-X-ENDLIST

What am I doing wrong ?

Kind Regards,

Vincent


More information about the ffmpeg-user mailing list