MichaelMathieu / THFFmpeg

Torch bindings for FFmpeg (reading videos only)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seek is unnecessarily slow

zanbri opened this issue · comments

The seek method is extremely slow when the parameter passed is large. Following an explanation here: https://trac.ffmpeg.org/wiki/Seeking , the seek parameter is now frame-accurate, even when passed as an input.

Is there a way to pass the -ss argument before the file path? It looks like the code change would have to be on line 238 of tthmpeg.c. I would make the change myself, but my knowledge of c is too rusty :/

if you replace av_seek with ff_seek or ffm_seek, i think it'll get faster.
See the "Referenced by" functions here:
https://www.ffmpeg.org/doxygen/3.0/avformat_8h.html#ab83ca408a574b40c76f681b616096fc8

The ffm_seek code says that it is 'quite approximative'. Although I didn't find an ff_seek function in the link you provided, a similar function named ff_seek_frame_binary doesn't state whether it is approximative. Do you know if that is a better one to use?

ffm_seek is what you want. It is fast because it is approximative (and there's no way to get precise and approximate looks like it, unless i am missing something)

I'll look into that in the coming weeks, if you are familiar with ffmpeg and want to do a pull request, please do :)