Hi Cyril, Thanks a lot for your reply.
I tried your suggestion and changed my first test to do frame accurate seeking by moving the -ss option upfront, like so: ffmpeg -ss 0 -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 4 -f mpegts sample_fa-0.ts ffmpeg -ss 4 -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 4 -f mpegts sample_fa-1.ts ffmpeg -ss 8 -i .source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 4 -f mpegts sample_fa-2.ts ffmpeg -ss 12 -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 4 -f mpegts sample_fa-3.ts ffmpeg -ss 16 -i source.ts -c:v libx264 -b:v 1000k -c:a aac -b:a 128k -g 25 -t 4 -f mpegts sample_fa-4.ts I then wrapped up the following m3u8: #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:4 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:4.000000, sample_fa-0.ts #EXTINF:4.000000, sample_fa-1.ts #EXTINF:4.000000, sample_fa-2.ts #EXTINF:4.000000, sample_fa-3.ts #EXTINF:4.000000, sample_fa-4.ts #EXT-X-ENDLIST Unfortunately, the playback in VLC stops after the first segment (and the audio is cut even before that) I wondered what the duration of the segments was, and using ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 sample_fa-<n>.ts with n = 0 to 4, it showed: 4.021333 4.021333 4.021333 4.021333 4.021333 So the duration for all segments is identical, but not exactly 4.000000 seconds. Could it be the reason ? I also tried moving the "-t 4" option to the beginning too, just after the -ss option, but it's even worse, because segment durations are variable then: 4.021333 4.381333 4.781333 4.421333 4.341333 (and playback also stops after the first segment) Do the TS segments have a specific "end of video" marker that would explain why playback stops (and that marker should not be present in HLS segments) ? Kind regards, Vincent On Tue, Jan 24, 2023 at 12:03 AM Cyril Comparon <[email protected]> wrote: > 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 <[email protected]> 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 <[email protected]> > > 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 > > [email protected] > > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > > > To unsubscribe, visit link above, or email > > [email protected] with subject "unsubscribe". > > > _______________________________________________ > ffmpeg-user mailing list > [email protected] > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > [email protected] with subject "unsubscribe". > _______________________________________________ ffmpeg-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
