Closed write2art closed 4 years ago
Hi @write2art,
[warn] > missing video frame(s), backtracking fragment...
indicates that you have segments that do not start with keyframes. I don't think backtracking goes back more than one segment, so you probably have multiple segments without any keyframes, unless there is an issue with decryption or parsing missing/loosing the key/IDR frames.
Can you share how your stream is encoded?
Hi @robwalch Sure, here it is:
ffmpeg -fflags +genpts+igndts -ss {$seek}{$duration} -i $input -y -movflags faststart -g 50 -keyint_min 50 -sc_threshold 0 -c:a aac -c:v libx264 -crf 21 -x264-params \"nal-hrd=cbr\" -filter_complex \
'[0:v]yadif,format=yuv420p,framerate=fps=25,setpts=N/(25*TB),split=4[v1][v2][v3][v4];[v1]scale=1920:-1[hd];[v2]scale=1280:-1[hq];[v3]scale=640:-1[mq];[v4]scale=512:-1[lq];[0:1]amerge=inputs=1[a];[a]aformat=sample_rates=44100,asetpts=N/SR/TB,asplit=5[a1][a2][a3][a4][a5]' \
-map '[hd]' -map '[a1]' -b:a 128k -ac 2 -b:v 6000k -minrate 6000k -maxrate 6000k -tune film -profile:v high -f mp4 {$dir}/{$uuid}_portal_HD.mp4 \
-map '[hq]' -map '[a2]' -b:a 64k -ac 2 -b:v 4000k -minrate 4000k -maxrate 4000k -tune film -profile:v main -f mp4 {$dir}/{$uuid}_portal_HQ.mp4 \
-map '[mq]' -map '[a3]' -b:a 64k -ac 1 -b:v 1500k -minrate 1500k -maxrate 1500k -tune film -profile:v baseline -f mp4 {$dir}/{$uuid}_portal_MQ.mp4 \
-map '[lq]' -map '[a4]' -b:a 64k -ac 1 -b:v 700k -minrate 700k -maxrate 700k -tune film -profile:v baseline -f mp4 {$dir}/{$uuid}_portal_LQ.mp4 \
-map '[a5]' -vn -ac 1 -f mp4 {$dir}/{$uuid}_mobile_AQ.mp4
As you can see, with frame rate 25 i have a keyframe every 2 seconds, which leads to at least two keyframes in every 4 seconds chunk.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
As you can see, with frame rate 25 i have a keyframe every 2 seconds, which leads to at least two keyframes in every 4 seconds chunk.
And then how are you packaging into HLS? If the chunks do not start on one of those keyframes, seeking either must drop frames or load two chunks before seeking is complete.
@robwalch the problem was during encoding. My settings applied only to the first out video, and other 3 streams were using the defaults. To make it insert keyframe every 50 frames i should duplicate keyframe settings for every output stream. Now everything works as expected.
Thanks for your replies - your mention about chunks should start from keyframe finally leaded me to a solution.
That's good. I'm going to close this one out as I'm not making plans to improve support for non-independent segments at the moment.
What version of Hls.js are you using?
0.13.2
What browser and OS are you using?
macOS Catalina 10.15.3, Chrome/Safari/Firefox
Test stream:
Sorry for the adult content, it's censored as much as possible, but still..
https://cdn.ntvplus.tv/hl-hls/broadcasts/v/a1/va1e3759e3d3a9665aa2c9f8db3f8b277_portal_LQ.mp4.m3u8
Checklist
Steps to reproduce
Expected behaviour
Video continues to play from chosen point
Actual behaviour
Actually there are two possible outcomes:
I've provided the log for both outcomes. The log starts with normal playback from the start, then i've added 2 logs after seek. Sometimes it works as expected though.
Console output