6 ms·
Making GIFs From Video Files With Python
- killahpriest 13y agoOriginally from/more discussion at http://www.reddit.com/r/programming/comments/1w2c58/a_few_animated_gifs_and_their_python_code_xpost/ http://www.reddit.com/r/programming/comments/1w2c58/a_few_an...
- lawsohard 13y agothis is awesome
- w1ntermute 13y agoPlease use silent HTML5 videos instead of animated GIFs wherever possible. They are much more bandwidth- and CPU-efficient. This site allows you to automatically upload/convert animated GIFs into that format: http://gfycat.com/ http://gfycat.com/ The links allow you to see the animated GIFs as well, if viewer's device doesn't support HTML5.
- sehugg 13y agoOne nice thing about GIF is that the format is not patent-encumbered. Same goes for MPEG-1.
- emilyst 13y agoThere's a drawback. Can we save these? Can we link directly to them?
- w1ntermute 13y agoYes, if you right click (at least in Firefox) there is an option to download the WebM file. And you can get a direct link, although that doesn't really make sense, since if you're sending it to somebody, they probably want the option of watching the WebM version or the GIF version.
- zulko 13y agoThe same scripts will output videos for HTML5 if you replace the `to_gif` method by `to_videofile`: clip.to_videofile('animation.mp4') clip.to_videofile('animation.webm', codec='libvpx') clip.to_videofile('animation.ogv',codec='libtheora')
- daliusd 13y agoCan I make video/gif from multiple photos?
- zulko 13y agoYou can do that with ffmpeg or ImageMagick. Something like ffmpeg -i *.png output.gif You have options like delay, loop, etc.
- lelandbatey 13y agoYep, that's how I do my gif conversions because it allows for much finer control, and often returns better results. I built an entire app around abstracting this technique: http://gifmachine.xwl.me/ http://gifmachine.xwl.me/
- daliusd 13y agoYes, I guess I could figure out such options but let me explain what problem I have. I take multiple photos (e.g. my camera can take 10 photos per second) and want to make video from that. Gif is poor option as photos are taken with hand and are shaky a little bit. Gif will get big in size because of that alone. Video (e.g. webm) is very good alternative for that. Your project (?) offers option to add text (and other nice little details) and that makes it killer alternative.
- jonesetc 13y agoI haven't used this, but it looks like this might be what you're looking for [1]. Construct with a folder name and framerate and then use the to_videofile method. https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/DirectoryClip.py?source=cc https://github.com/Zulko/moviepy/blob/master/moviepy/video/i...
- Recoil42 13y agoThe problem, for me, is that HTML5 video is a technical solution with no social advantage. There are so many places on the web where images are allowed that videos will never be allowed -- for good reason. Forums, comment threads, etc. What we need is an image container format that allows for a silent (and only silent) video stream to be embedded. A better GIF. Something that site maintainers would feel entirely comfortable in allowing.
- skymt 13y agoA new format would be overkill. Websites can just set the "muted" attribute on video elements. If you also set "loop" & "autoplay" and hide the controls, you've got a video that acts just like a GIF.
- HowardJ 13y agoWhy don't the powers that be make a new image animated image format that is bandwidth conservative? I don't get why Google/Apple/Microsoft/Adobe haven't jumped on this. Or maybe I do, they don't use animated GIFs. Fuck. If only Reddit/imgur/Internet forums had any lobbying power.
- nl 13y agoThis! (Although if the sound thing is such a problem then perhaps the muted attribute should be set to true by the hosting site?) Here's an idea: <img src="video.mp4">. Updated semantics should be the same as the video tag.
- tonetheman 13y agoNope nope nope. A gif is a single file and pretty much works everywhere. If you have the time to do it yeah maybe. But for animated cat pictures with titles... http://blog.zencoder.com/2013/09/13/what-formats-do-i-need-for-html5-video/ http://blog.zencoder.com/2013/09/13/what-formats-do-i-need-f... One of the big failures of HTML5 videos is the missing viral aspect. I can see a funny gif, then save it and then email it on to whoever and they can watch it. Hopefully all of this will play out and it will be easier, now it is not.
- Sir_Cmpwn 13y agoTry https://mediacru.sh https://mediacru.sh instead of gfycat. It has a lot more features, and it's open source [1]. It's been around the HN block a few times [2][3]. Disclaimer: I made it with a friend and I'm baised. [1] https://github.com/MediaCrush/MediaCrush https://github.com/MediaCrush/MediaCrush [2] https://news.ycombinator.com/item?id=6773039 https://news.ycombinator.com/item?id=6773039 [3] https://news.ycombinator.com/item?id=6189397 https://news.ycombinator.com/item?id=6189397
- joi_degn 13y agoIm baised... I really like that expression and will start using it :D
- olssonm 13y agoNice! Also check out: "Stupid programmer tricks and Star Wars .gif": http://rarlindseysmash.com/posts/stupid-programmer-tricks-and-star-wars-gifs http://rarlindseysmash.com/posts/stupid-programmer-tricks-an... Also Python, but uses VideoLan (VLC) to some extent to create really nifty Star Wars gifs.
- pronoiac 13y agoThis is nifty! Though it's tempting to draft a GUI for it.
- donbronson 13y agoThis is awesome and much easier than writing FFMPEG commands (which is what I do now). An enhancement could be adding voice to text.
- gioi 13y agoThank you! I've never met MoviePy and it looks really good. I'm waiting for libopenshot to be released, what do you think about it?
- mattdeboard 13y agoVery nice API.
- idoco 13y agoI just watched the whole 'Pigs in a polka' video and it is so good! The API is also very cool :)
- theophrastus 13y ago(on 'jessie'): apt-cache search 'movie.<asterisk>python|python.<asterisk>movie' ... <squatmo-germane> ... well, nutz. (and how the hell do you type a real asterisk in this comment forum? tried escapes... tried html entities...)
- maxerickson 13y agoFor code, just put a couple spaces before the line: apt-cache search 'movie.*python|python.*movie' In general, you can also stick a space after them * * *.
- theophrastus 13y agothank you. i would've never thought of that. * *
- Chromozon 13y agoVery well made tutorial.
- radoslawc 13y agoNice, kept me occupied for an hour :) also I must say author did a great job with module and documentation.
- JoshTriplett 13y agomplayer can do this as well: mplayer videofile -vo gif89a:fps=15:output=video.gif You can use mplayer's other options to set the start time, duration, and cropping.
- drakaal 13y agoAnyone done a benchmark of this vs AVISynth? I have software I wrote in AVISynth for doing 2d to 3d Stereoscopic upconversion based on motion and parallax. I have often wished I had it in something more "real" like Python.
- 0x09 13y agoHave you tried VaporSynth? It's kind of a spiritual successor to AviSynth in the form of a Python module. Can even load AviSynth plugins.
- na85 13y agoIsn't this overkill? You can get the exact same result with FFMPEG and a single shell command. Seems like a solution in search of a problem.
- ivanca 13y agoCan you easily integrate django with a shell command? Or with the python imgur image hosting? Easy online creation of gifs seems kind of useful.
- jrockway 13y agoThis is much nicer than my normal method of getting the frames with mplayer -vo png and then using ImageMagick to assemble the frames into an animated GIF.
- lassse 13y agoI use http://www.gifrocket.com/ http://www.gifrocket.com/ for Mac.
- stephenitis 13y ago@Schneems has a really good tutorial on this using ffmpeg. http://www.schneems.com/post/41104255619/use-gifs-in-your-pull-request-for-good-not-evil/ http://www.schneems.com/post/41104255619/use-gifs-in-your-pu...