[FFmpeg-user] Generating HLS chunks on demand
Cyril Comparon
cyril.comparon at gmail.com
Tue Jan 24 01:02:45 EET 2023
Hi Vincent
I believe what you're looking for is frame-accurate seeking.
To achieve that you have to do input seeking instead of output seeking. The
former is achieved by specifying -ss before -i in your command line,
whereas you're doing the latter by specifying -ss after -i.
See https://trac.ffmpeg.org/wiki/Seeking
HTH
Cyril
Le lun. 23 janv. 2023 à 09:15, Vincent Deconinck <vdeconinck at gmail.com> a
écrit :
> Hi,
>
> I performed more tests thinking that maybe the -f mpegts did not create
> "hls-compliant" ts chunks (whatever that could mean).
> So I tried creating first a full hls with the following command :
> ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -f hls
> -hls_time 4 sample.m3u8
> This took a long time to process the full video of course, but the result
> plays perfectly fine.
> I then created a partial version limited to 12 seconds (=3 chunks of 4
> secs) from the same source, as follows:
> ffmpeg -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 12
> -f hls -hls_time 4 sample_part.m3u8
>
> I performed a binary diff on the resulting ts files, and the chunks #0 and
> #1 are exactly the same.
> However, chunk #3 (which is the last of the "partial" version) is different
> (375kB vs 392kB) :
>
> 1578 sample.m3u8
> 190 sample_part.m3u8
> 582424 sample_part0.ts
> 764972 sample_part1.ts
> 383896 sample_part2.ts
> 582424 sample0.ts
> 764972 sample1.ts
> 401004 sample2.ts
> ...
>
> What is the reason for that difference, and how can I make sure I generate
> a valid segment for those 4 seconds ?
>
> Kind regards,
>
> Vincent
>
> On Fri, Jan 20, 2023 at 5:44 PM Vincent Deconinck <vdeconinck at gmail.com>
> wrote:
>
> > 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
> >
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-user
mailing list