Skip to content
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 short videos thumbnail generation #765

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

glubsy
Copy link

@glubsy glubsy commented Nov 11, 2020

  • Use ffprobe/avprobe to get the total duration of each video file first.
  • Compute a desired optimal timestamp of 50% of the total duration to seek for and get the thumbnail from.
  • Fix capture of ffmpeg's output (from stderr) in exec_cmdv() by using an optional redirection to stdout.
  • Capture of sub-process output is optional (possible slight performance gain).

This fixes #763, fixes #565, fixes #754, fixes #436, fixes #695.

@glubsy
Copy link
Author

glubsy commented Nov 29, 2020

commit 8280aff fixes #695.

Keep the default assignment in case there are more types.
* Use ffprobe/avprobe to get the total duration of each video file first.
* Compute a desired optimal timestamp of 15% of the total duration to seek for and get the thumbnail from.
* Fix capture of ffmpeg's output (from stderr) in exec_cmdv() by using an optional redirection to stdout.
* Capture of sub-process output is optional (possible slight performance gain).
Overwrite already existing thumbnails if the source file's mtime is more recent
* Return stdout as expected from ffprobe to get duration.
* Avoid throwing an exception in favour of a default value for potential
malformed total duration got from ffprobe.
* Conflict with the newly added boolean arguments if they are
explicitely passed by the caller.
* cmdv has to be an array.
* Allows users to specify which percentage of the total video duration
to seek in instead of hardcoding 15%.
* Now defaults to 50%.
* This fixes a denial-of-service exploit that would allow the client to
generate an infinite number of thumbnails and fill up the storage completely.
Since the client had control over the requested thumbnail sizes, it could make arbitrary requests for thumbnails, and every time the backend did not find an already generated thumbnail with the specified sizes, it would happily generate a new one.
* Remove the ability of the client to decide thumbnail dimensions and
only let the back-end do this by reading the configuration.
* Limit the number of generated thumbnails per file to only one, with
"landscape" dimensions (4/3).
* Use CSS "object-fit" property to adjust displaying of landscape thumbnails into squares. Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
* This fixes a denial-of-service exploit that would allow the client to
generate an infinite number of thumbnails and fill up the storage completely.
Since the client had control over the requested thumbnail sizes, it could make arbitrary requests for thumbnails, and every time the backend did not find an already generated thumbnail with the specified sizes, it would happily generate a new one.
* Remove the ability of the client to decide thumbnail dimensions and
only let the back-end do this by reading the configuration.
* Limit the number of generated thumbnails per file to only one, with
"landscape" dimensions (4/3).
* Use CSS "object-fit" property to adjust displaying of landscape thumbnails into squares. Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
* We now use only one thumbnail file src for both square and rational
thumbnails so remove superfluous requests.
* Set the same src for both square and landscape dom classes.
Only compute thumbnail configured dimensions on thumbnail API requests.
@Hi-ImKyle
Copy link

Hi-ImKyle commented Sep 6, 2022

I built your forks master branch and the webpage is just a broken page

image

You don't have issues open on your fork so I'm putting it here.
Is the master branch even the correct one to use? I want all of the features you've implemented into h5ai in one package if thats possible.

@glubsy
Copy link
Author

glubsy commented Sep 7, 2022

@Hi-ImKyle I have enabled issues just now thanks for the heads up. Yes master branch includes all my changes. No idea what your issue is, does this happen with the original version of h5ai? What server are you using? What php version? What do you see in the developer console in the web browser?

@Hi-ImKyle
Copy link

I'll create an issue on your fork instead of polluting this one~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants