-
Notifications
You must be signed in to change notification settings - Fork 827
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 MP4 engine to support producing webp/gif directly from mp4 #899
Conversation
Heya @winguse! Thanks for this PR! First of all, gratz for you first Python code :) Way to go! We've been talking about a better way of adding new Engines to Thumbor, but the actual code has some issues that needs to be addressed first. Right now, through configuration, we are only able to change an Engine for all images or change an Engine for gifs, separately. The only way to add a brand new Engine for another mimetype is, as this PR did, adding another if to the e.g.: Config.define(
'ENGINES', [
('video/mp4', 'thumbor.engines.mp4'),
('image/gif', 'thumbor.engines.gif'),
('default', 'thumbor.engines.pil'),
] With that being said, I'd like to propose that: 1- This PR would be only about adding a new mp4 Engine. I'll take care of 3 and will link it in here ASAP. Then again, thank you for the PR and keep up the good work! |
Thanks @andreaugusto , good to know we can avoid ifs, that should be a good idea. 👍 |
Using this PR as a starting point, I created a thumbor engine that can handle reading and writing videos (thumbor-video-engine). It uses the video engine for video files, and passes non-video files to |
We're in the process of reducing thumbor's codebase and we'll only keep one example implementation of each concept (loader, storage, engine, etc) with some exceptions. I highly encourage you to push this to a project that people can just install alongside thumbor and plug it in. |
In the PR, I implemented a new engine for producing
webp
/gif
frommp4
. In my case, I want to serve my users animated images from videos. (webp
will be returned only whenAUTO_WEBP=True
)I have an original idea that transcode video into gifs, but the gifs are too large and bad in quality.
webp
is very good, but some devices do not support it.I also considered saving the
webp
as the source file to be converted togif
when needed, butffmpeg
do not support decoding the animatedwebp
currently. So in this PR, I am using a pretty tricky hack to save the source file: return the originalmp4
buffer whenread(extension='.mp4', quality=None)
.I started learning Python only a few days ago and had never wrote so much Python, please help to correct me if I made any stupid mistakes.
Thank you!