FFmpeg: Improve performance by seeking input rather than output video - #3893
Conversation
This improves performance when converting video to images as we no longer have to decode and then discard the first x seconds of video.
|
Excellent! I wasn't aware that changing the parameter order helps in this case. |
|
An updated development preview build is available for testing: |
|
@alexspurling I've tested it with a few large videos and it seems to be much faster now. Thank you very much! ❤️ |
|
FWIW (but I don't think it really matters here), this makes the seek less accurate, as ffmpeg can only seek to the beginning of a GOP when not decoding, so you usually end up a few seconds before the desired timestamp... OTOH, this means we end up on an I-frame, which usually has slightly better quality. |
We value your feedback and insight! Happy to implement further improvements if needed.
I agree, that's actually an advantage, as time accuracy is not important for this use case. |
This improves performance when converting video to images as we no longer have to decode and then discard the first x seconds of video.
The current code creates an ffmpeg command like this:
This tells ffmpeg to decode the first 30s of the input before extracting a frame and writing it as a jpg.
This pull request changes the ffmpeg command to:
This tells ffmpeg to efficiently seek to the desired frame, write the jpg and then exit. This results in a significant speed up when importing large video files.
Log file before:
Log file after:
Acceptance Criteria: