-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(previews): avoid large file downloads for remote movie storage #52079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(previews): avoid large file downloads for remote movie storage #52079
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to get only the end of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@printminion-co I was not able to reproduce the full download locally. Is there anything specific about your setup? Maybe it is the S3 bucket?
Could it be that your S3 bucket does not support partially seeking the file? Not sure exactly what would be missing. Maybe @juliusknorr or @icewind1991 know better?
Also, I assume that in your testing, the full download was triggered by the null
option, meaning that the 5242880
was failing. Do you have any error message related to that?
My goal would be to try to fix the partial download instead of dropping the functionality.
I guess that is what @printminion-co mentions that with this specific video file the relevant bits are at the end so it always requires the full read. I'm not sure if it also may also depend on other factors like the ffmpeg version used if a preview can be generated without the moov atom. From my POV it would be acceptable to not have previews in those cases, though from a user perspective it may be unexpected to see some previews of videos, but not all. |
Ha, we had a ticket on that topic literally a few days ago. Some files are also more error prone, like MOV files are terribly optimized for streaming for that reason, moov atom section is almost never in the early strt of the file 😢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make it easier to read.
9fdd39c
to
42b86e1
Compare
42b86e1
to
68b8d8b
Compare
The functionality will be dropped on files larger than 5Mb on which the ffmpeg thumbnail generator will get the
Probably NC admins with S3 backend could later via config define their own upper re-download limit they are ok with (e.g. 50mb) |
Prevent downloading entire movie files from remote storage (e.g., S3) when the 'moov atom' is located at the end of the file. Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
68b8d8b
to
4a924bf
Compare
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
/backport to stable31 |
Apologies for being late to the discussion, but to my untrained eye, it seems this would affect all non-local shares, including SMB? If that is the case, that is unfortunate, as I have a library of videos larger than 5MB that is mounted as external storage in my NC instance. Previews have already been pre-generated for all of them so I won't notice any difference personally, but although these files are technically stored "remote", they are actually on the same server (for reasons I won't get into) so the connection speed is very high. Even if these were mounted remote but on a LAN, larger files than 5MB could still be accessed fairly quickly. I've been racking my brain all night to see if there's a better way to deal with the problem of having to download the entire file but thus far my research is indicating it's not possible. ffprobe/ffmpeg supposedly have methods of accessing the S3 to allow seeking to the end to fetch the moov atom without requesting the entire file, but the problem is NC's temp file mechanism added in the middle that wouldn't allow this to work. For testing purposes, I've made efforts to brute force trim the front of a video file off down to the last 500KB or so (which should be plenty to cover the moov atom) but this results in ffmpeg/ffprobe failing with a moov atom not found error. |
For what it's worth, I came across the following two threads during my research: And: Is there a reason why NC preview generation is written to call the ffmpeg binary directly as opposed to using PHP-FFMpeg? Not that this would solve the issue... But supposedly passing a signed URI directly would work |
Is also calling the binary directly (through binarydriver and symfony process) |
Still digging around and thinking about how to implement this but buried in common.php is this:
...which would be exactly what's needed to pass directly to |
@printminion-co I would love it if you could give my PR a test and let me know how it works for you. |
You mean probably the #53634 |
Yes, that's the one. |
Summary
Error produced by ffmpeg
Proposed Solution
Prevent downloading entire movie files from remote storage (e.g., S3) when the 'moov atom' is located at the end of the file.
Test
Can be tested (locally with Minio) with video files larger than 5Mb with "moov atom" at the end of the file
Download sample video with missing "moov atom" at the beginning of the file
wget https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_10mb.mp4
Checklist
html#integration-tests), api and/or acceptance) are included