Add MP4 engine to support producing webp/gif directly from mp4#899
Add MP4 engine to support producing webp/gif directly from mp4#899winguse wants to merge 20 commits into
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/giffrommp4. In my case, I want to serve my users animated images from videos. (webpwill 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.
webpis very good, but some devices do not support it.I also considered saving the
webpas the source file to be converted togifwhen needed, butffmpegdo not support decoding the animatedwebpcurrently. So in this PR, I am using a pretty tricky hack to save the source file: return the originalmp4buffer 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!