Discussion:
[FFmpeg-user] HLS accurate seeking vs MP4
Louis Letourneau
2018-10-10 02:39:27 UTC
Permalink
I seem to be having issues seeking accurately in HLS videos, but it
works fine in other containers (mp4, mkv, etc)

tried with ffmpeg version 3.4.4 and master

If I create an HLS video like this
mkdir a;ffmpeg -y -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i
/dev/zero -vf "drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeMono.ttf:
text=%{n}: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1:
boxcolor=0x000000FF" -an -vcodec libx264 -preset medium -tune
stillimage -crf 24 -pix_fmt yuv420p -shortest -force_key_frames
"expr:gte(t,n_forced*5)" -bf 0 -hls_time 5 -hls_list_size 0 -hls_wrap
0 -hls_allow_cache 1 -hls_segment_filename "a/a_%04d.ts" -t 60
a/a.m3u8


And also create it's mp4 counterpart:
ffmpeg -i a/a.m3u8 -codec copy a.mp4


And try to seek in any segment:
F=130;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a/a.m3u8 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got frame 250 (bad)

F=126;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a/a.m3u8 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got frame 250 (bad)

F=125;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a/a.m3u8 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got frame 125 (good)

F=124;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a/a.m3u8 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got frame 125 (bad)


Now try the same with the mp4 and you'll always get the exact right frame
F=130;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a.mp4 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got 130 (good)

F=126;rm -f f.png;ffmpeg -y -ss `awk "BEGIN {print (${F})/25}"` -i
a.mp4 -f image2 -q:v 1 -vframes 1 f.png ; feh f.png

Got 126 (good)
etc

it seems to be seeking on segment boundaries only.

Of course, if I put -ss after the input '-i' I seek accurately but
it's an output parameter now so it takes much longer since it's
decoding all the frames (also doesn't work with multiple input maps).
And according to 'https://trac.ffmpeg.org/wiki/Seeking' input seeking
should be accurate

Is this a bug or I am missing a parameter?

(BTW, I posted this same question in Nov 2016 without a valid answer.
If no one can answer this time, I'll open a bug)

Thanks
Louis
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with
Nick Ryan
2018-10-10 09:05:33 UTC
Permalink
Post by Louis Letourneau
I seem to be having issues seeking accurately in HLS videos, but it
works fine in other containers (mp4, mkv, etc)
Hello,

Refer to this issue which sounds the same/related/similar:

https://trac.ffmpeg.org/ticket/7359

I fixed this in my own ffmpeg build with this:

https://patchwork.ffmpeg.org/patch/10494/

Nick





_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscribe
Louis Letourneau
2018-10-10 16:29:34 UTC
Permalink
Post by Nick Ryan
Post by Louis Letourneau
I seem to be having issues seeking accurately in HLS videos, but it
works fine in other containers (mp4, mkv, etc)
Hello,
https://trac.ffmpeg.org/ticket/7359
https://patchwork.ffmpeg.org/patch/10494/
Nick
sorry for the top post,
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with sub
Nick Ryan
2018-10-24 12:58:10 UTC
Permalink
Not the same problem and patch doesn't fix the issue at all.
Louis
Post by Nick Ryan
Post by Louis Letourneau
I seem to be having issues seeking accurately in HLS videos, but it
works fine in other containers (mp4, mkv, etc)
Hello,
https://trac.ffmpeg.org/ticket/7359
https://patchwork.ffmpeg.org/patch/10494/
Nick
Hello again Louis.

Agreed that the fix I suggested last time didn’t work. I actually discovered it didn’t fully fix the issue I was trying to fix as well.

However, I have now submitted a new patch which correctly fixes the issue I was solving.

I took the time to reproduce your issue outlined in your original post. I managed to reproduce it and then resolve it with this new patch.

The patch I submit has changes to his.c (relevant to your issue) and to mov.c (not relevant to your issue).

http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235524.html <http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235524.html>

https://patchwork.ffmpeg.org/patch/10767/ <https://patchwork.ffmpeg.org/patch/10767/>

Regards,
Nick


_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscribe"
Louis Letourneau
2018-10-25 17:44:38 UTC
Permalink
Post by Nick Ryan
However, I have now submitted a new patch which correctly fixes the issue I was solving.
I took the time to reproduce your issue outlined in your original post. I managed to reproduce it and then resolve it with this new patch.
The patch I submit has changes to his.c (relevant to your issue) and to mov.c (not relevant to your issue).
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235524.html <http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235524.html>
https://patchwork.ffmpeg.org/patch/10767/ <https://patchwork.ffmpeg.org/patch/10767/>
Regards,
Nick
Your patch works like a charm. This issue has been a thorn on my side
for 1.5 years now. Thank you so much.
I also added a link to your patch in my ticket:
https://trac.ffmpeg.org/ticket/7485

Louis
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "u

Loading...