-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
add gatsby-transformer-video (beta available) #15783
Conversation
Generally GIFs should never be used on the web - https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/replace-animated-gifs-with-video/ |
@me4502 while I'd agree, exposing So... noted, but I think it's reasonable to provide it so we could create e.g. |
Currently thinking of providing one field per codec. Opens up flexibility and would remove that preview field. That way users could generate a gif which way less fps as the other previews. Or just simply provide a jpg as preview. |
Did not try it out yet but the following should speed up the playback start delay:
|
FYI: planning to work on this on christmas holidays :) |
I personally have been pre-encoding all videos with the recommendations from here, https://gist.github.com/mikoim/27e4e0dc64e384adbcb91ff10a2d3678 These seem to perform super well, but the benefits of this plugin to allow better sizing / multiple formats will be amazing! :) |
So my idea is to refactor this till end of the year, including all the given feedback and especially:
So instead of a To use the current version of the plugin you would do something similar like: fragment BlogPostData on BlogPost {
...
mediaFieldWithVideoData {
# convert source video into optimized for web version with default settings
video {
h264
h265
}
# Create a preview version of the video with reduced dimension, speed up and very limited frames per second
videopreview(width: 600, fps: 4, duration: 3) {
mp4
webp
gif
}
}
} While the refactored way I propose would allow you way more fine granular configuration. Which is necessary as video conversion is complex and the settings depend on a lot of content and project specific factors. fragment BlogPostData on BlogPost {
...
mediaFieldWithVideoData {
videoH264 (maxBuffer: '2M', ...) {
path
size
}
videoH265 (maxBuffer: '1M', fancyH265Setting: 'bar', ...) {
path
size
}
previewMp4: videoH264 (desaturate: true, width: 600, fps: 8, duration: 3) {
path
}
# Note that we can give the gif way smaller dimensions to reduce preview file size for clients without mp4 support
previewGif: videoGif (desaturate: true, width: 300, fps: 4, duration: 3) {
path
}
...
}
} |
sorry Kyle - this must done by mistake - i don't remember doing something like this :( |
99e9e2b
to
2435cf2
Compare
So refactoring is done to have one field per codec. Additionally it uses the new schema customisation API and removes all code-smells from the last reviews. This plugin now adds the following subfields to all file nodes:
Next steps:
|
I implemented VP9 and some performance & quality improvements for h264/h265. Thanks to https://developers.google.com/media/vp9/settings/vod/#bitrate we can even automatically determine a fitting bitrate based on our source data and given field args (like maxWidth) The generated files now have a decent (not super high) quality, small file size and the file sizes differ as expected based on coded.
I won't claim the settings are perfect but its a clear improvement to the first version :) |
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.
some suggestions
Crunching more numbers: I got 7 source videos, mostly 720p from iPhone cameras or final cut, converting it in 3 target videos including 3 additonal previews. It takes about ~16 minutes to convert all videos on my i9. (query below) Gatsby cloud took 1h 5min to convert all of it. Restarting the build with the same cache, 30 seconds build time 💪 😍 query ExampleQuery {
contentfulAsset(file: {contentType: {regex: "/^video/"}}) {
title
file {
contentType
fileName
url
}
videoH264 {
path
}
videoH265 {
path
}
videoVP9 {
path
}
previewH264: videoH264(maxWidth: 560, fps: 4, duration: 2, saturation: 0) {
path
}
previewWebP: videoWebP(maxWidth: 560, fps: 4, duration: 2, saturation: 0) {
path
}
previewGif: videoGif(maxWidth: 280, fps: 4, duration: 2, saturation: 0) {
path
}
}
} |
9359d37
to
60eeaa8
Compare
Next refactoring is done, took everything @muescha mentioned into account. The code should be more flexible and readable as well as I moved the codec specific code into a subdirectory, one file per codec/profile Implementing the custom profile function should now be pretty low efford :) I will do a complete local run on my machine and publish |
… of a broken or unsupported file
db8dbe9
to
375f1a0
Compare
I cleaned up the code and applied several fixes and improvements we stumbled upon while using v0.1 in actual projects. 0.2.0 (2020-11-02)Build System / Dependencies
Chores
Documentation Changes
New Features
Bug Fixes
Refactors
Code Style Changes
|
…tio to type definition
Planning on a v0.3 release that supports Gatsby v3, is less spammy in the logs and actually caches screenshots/poster images |
@axe312ger Would it make sense to move this into its own repo? It's not going to be merged any time soon, and publishing releases from a branch isn't great practice. |
@ascorbic yeah maybe we should do that. But I was hoping to not end up alone as maintainer 😇 |
cc @KyleAMathews what do you suggest here? I rather not add it to the monorepo as we don't have any knowledge or time to dig into this. We also don't add ffmpeg to cloud so this wouldn't work there. |
it does work, just needs to download a 90mb zip with two binaries 🙈 |
I love the idea of this but... if image processing trips up a lot of people using Gatsby, well, video processing is like the sun to image processing's little match. It's immensely expensive & I don't think people would have a good experience using a video transform plugin. I think most people would be much better off using a dedicated service for video hosting. There's some sites for sure where this transformer would be great but I don't think the number is enough that we'd want to make it an official project. |
Yes, and if sharp causes people issues, ffmpeg is another level. This is a great plugin, but making it official would take a lot of work, including fixing caching. |
Fixing/improving the cache would be very helpful, for this plugin, but also for others 🙃 |
I'll move this out of this repo and make a community plugin out of it as soon I find time for it. When doing this, I'll also rewrite to Gatsby v3 and maybe to TS. |
There's now an experimental flag to enable retaining downloaded assets when auto-cleaning. I wonder if that will be enough to let this use the regular asset cache? |
Sounds good. You will hear from me for sure when I move this code 😅 |
Hello everyone, I moved the code of this PR to its own repository: https://github.com/hashbite/gatsby-transformer-video Also Hope to get some collaboration going in the new repo, see ya over there 👋 |
This integrates fluent-ffmpeg with Gatsby 🎥
npm i gatsby-transformer-video
Features
gatsby-source-filesystem
andgatsby-source-contentful
fluent-ffmpeg
to unlock all FFMPEG features.Todos:
.node_moduels/.cache
and queue our FFMPEG executions on our own. This is just a workaround as Gatsby has no system to queue such time consuming transformations. We as community should implement an API that allows all plugins play well next togatsby-transformer-sharp
, this video transformer & others.