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

Convert user uploaded animated GIFs to videos #7232

Closed
swissspidy opened this issue Apr 16, 2021 · 8 comments · Fixed by #7528
Closed

Convert user uploaded animated GIFs to videos #7232

swissspidy opened this issue Apr 16, 2021 · 8 comments · Fixed by #7528
Assignees
Labels
Group: Video Optimization Media transcoding, compression and cropping P2 Should do soon Type: Enhancement New feature or improvement of an existing feature

Comments

@swissspidy
Copy link
Collaborator

Feature Description

Since we now have all the pieces to do use FFmpeg in the editor and force cross-origin isolation, it would totally be possible to optimize a user-uploaded animated GIF by automatically turning it into an MP4. In the editor this would use the "hidden" GIF element we already use for Tenor GIFs (which are also actually videos).

Not only would it be possible, but it should also be quite trivial to implement:

During upload:

  1. Upload GIF file
  2. We check whether the GIF is animated (perhaps with something like https://gist.github.com/marckubischta/261ad8427a214022890b)
  3. If GIF is animated, run through FFmpeg
  4. Create GIF element with the video
  5. Create poster image for the video

Existing images:

  1. Just like for non-optimized videos, offer a button to optimize GIF, which will optimize it behind the scenes

Alternatives Considered

This might not be a high priority since not many users might be uploading animated GIFs to WordPress / stories.

Additional Context

Related: WordPress/gutenberg#19730


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

Implementation Brief

@swissspidy swissspidy added Type: Enhancement New feature or improvement of an existing feature P3 Nice to have Pod: WP & Infra Group: Video Optimization Media transcoding, compression and cropping labels Apr 16, 2021
@swissspidy
Copy link
Collaborator Author

cc @o-fernandez @pbakaus

@spacedmonkey
Copy link
Contributor

This is an interesting read - https://github.com/cyburgee/ffmpeg-guide

@swissspidy
Copy link
Collaborator Author

Here's a proof-of-concept demo:

GIF.2.Video.mov

Poster generation works too, it's just not reflected in the media library yet.

The underlying data structure for GIF resources needs to be adapted a little bit, but it looks really promising already.

@spacedmonkey
Copy link
Contributor

Is the poster image the originally uploaded image?

@swissspidy
Copy link
Collaborator Author

Is the poster image the originally uploaded image?

In my PoC the poster image is a freshly generated, still image of the video's first frame. Just using the GIF would negate any benefits of using videos in the first place, because the browser would then download a large GIF and a video, which would just make things worse.

@swissspidy swissspidy added P2 Should do soon and removed P3 Nice to have labels May 10, 2021
@swissspidy swissspidy self-assigned this Jun 23, 2021
@csossi
Copy link

csossi commented Jul 7, 2021

poster not generated after video optimization completed for animated gif:

image.png

@swissspidy
Copy link
Collaborator Author

@csossi Well spotted! Since GIFs are technically images to the user's eyes, there's no poster image section under "Accessbility" for GIFs. This is the same behavior as today, when inserting a GIF from Tenor for example. So this is expected behavior.

@csossi
Copy link

csossi commented Jul 8, 2021

Then all is well, @swissspidy

Verified in QA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Video Optimization Media transcoding, compression and cropping P2 Should do soon Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants