I would suggest ffmpeg as an alternative -- it peels, it slices and it dices. It will definitely convert a range of a video file to gif while adding subtitles, and you won't have to frankenstein things together..
Totally agree, although the author's use of vlc definitely qualifies as a clever hack.
I want more hackers to realize how insanely easy it is to programmatically generate video with ffmpeg. Just write a program that dumps raw RGB frames to stdout! You can turn that into any video format conceivable, including gif.
Here's a little demo I wrote. Generates a video of the Mandelbrot set coming into focus:
Interesting! At work I hacked together a video writer that compiles still frames to a movie using OpenCV. But it is slow --ungodly slow. I'll have to check out ffmpeg!
You must have a very different experience of email than I do. That sounds absolutely terrible to me. Am I missing some reason that this would be useful, or is this just a case of wildly diverging preferences?
Our product (Interactly) is virtual video interactions, so our main value prop is being able to see real people respond.
In that context we figured it would be interesting to see if we could include a 5 second GIF intro right into the notification email; mostly out of curiosity just to see if it would technically be possible.
I was surprised to find out it was mostly feasible, but you're right that it doesn't make sense beyond the fact that it would be a cool gimmick.
Indeed, I have to vouch for ffmpeg as a the best solution. When I built GifMachine[0], it's pretty much just a web interface and automation layer to ffmpeg/imagemagick. Imagemagic and ffmpeg I found to be easy to use, fast, and delightfully scriptable. Using them together also produces the prettiest results.
The arguments to the gstreamer binary are encoders,decoders,filters and i/o piped together like commands in a shell (with the ! operator). For example, this is a shell command to show a h264 network stream on a raspberry pi:
Remember when you first discovered programming? When you did all those little projects that were, honestly, fairly useless, but brought you the spine-tingling sensation of having power over your domain?
Remember how when you started programming professionally, and you quit those projects? Why did that need to happen?
Bravo Lindsey, never stop making cool things.
(YMMV. I'm assuming of course that you learned programming as a hobby--if you learned by taking a college course then gasp you might have skipped the pointless-project phase entirely. I suggest you get on top of that.)
> Remember how when you started programming professionally, and you quit those projects? Why did that need to happen?
It didn't, I now get to spend 8+ hours a day working on things that matter, things that get me paid, thinks that make my customers (and their customers) happy, things that I see people use daily on their phone on my way to my next assignment.
Just because I work for a boss - and no, not some cool startup in the Valley - doesn't mean I don't do cool projects anymore.
(My pointless project phase was amongst others a scraper for InvisionFree forums, they would charge hundreds of dollars to get a copy of the database of a <50.000 post forum - and ours was over half a million posts big)
Very, very cool. I love the approach, especially the interface that ties it all together! Nice trick to use subtitle files to grab the right bit of video automatically, too.
If anyone is thinking of doing something similar, or just wants to script some video in some way, I can highly recommend AviSynth. It fits into the extremely flexible DirectShow pipeline and has earned a permanent place in my video editing toolchain (I use it as the frameserver for encoding DVDs).
Here's an example script (if you have AviSynth installed and create a file with these contents named hello.avs, you can open it in any media player you choose to see the results):
Take this approach and apply it with CSS, a web framework, and a DB and you can go quite far in the .com game. You'll run into problems if you get popular, but that's a good problem to have.
And yet, you won't - it mostly depends, I think, where your video comes from. gifsoup (iirc) will scrape a youtube video and turn it into a .gif. There's probably quite a few youtube-to-gif services out there, come to think of it.
It'll be a problem if you use the original star wars video in one way or another though. I think. Depends on whether it can be considered fair use or not.
Assuming a random distribution of quotes from the twitter stream, and assuming there isn't any control on repeats, how long can we expect to be able to recreate the movies (well, the portions with dialog) in gif form?
Not being good at ffmpeg, if I were to run it on a file with subtitles in the file (The most recent episode of an Anime for example), would it burn the subtitles in?
The subtitles files you can find online are formatted with timestamps to allow the video player to sync the text with the video, so for this purpose it makes perfect sense. Maybe set top boxes could make use of subtitles to allow users to search for a certain point in a video.
I did something similar (http://markolson.github.io/storyboard/) earlier this year using ffmpeg and ImageMagick to generate either GIFs around lines of dialog (like this project), or PDFs where each page is a frame of text or a new scene. Optimizing GIFs is by far the least enjoyable part.
The prevalence of the animated GIF is an eloquent statement about the current video encoding mess. While the typical small video clip today, encoded in a fancy new standard, is orders of magnitudes smaller that the JS+CSS+HTML site containing it, we use GIFs because nobody has any idea who is able to see the content is using a modern endoder.
Was really informative to read. I am a novice in every programming aspect, as I am formally a product (or content) manager.
But using python as my tool for answering my bosses questions with data, I really enjoy reading posts like these, giving me ideas to learn and try new things.
This is awesome! I had no idea that you could programmatically do this (I still consider myself a novice even though I've been professionally coding for two years). Very, very cool!
I wonder how hard it would be to introduce a cut detector, so that the (to me) annoying cinematic cuts that are sometimes at the beginning or end of a quote can be trimmed off. I think a simple heuristic of something like "If the frame cuts in the last half-second of the gif, trim off the extra frames" would work well, although I don't know how well a simple detector would work, nor how many quotes have a reaction shot that would get cut off unnecessarily.
I also enjoy gifs. I have been creating gifs with VirtualDub so far.
I usually prefer writing scripts to do stuff but VirtualDub is one of the few tools I simply use because I enjoy the open source and hacker spirit behind it.
An interesting plugin I miss for VD is an color reduction algorithm which would help to create very small gifs.
On reddit and tumblr gifs are a growing trend and it might be worth to put some effort into gif creation.
Am the only one who puts animated GIFs in the same category as the blink and marquee tags? Absolutely hate when there is more than one of these attention-seeking horrors on the page.
I've had to stop reading github's blog since they started putting thousands of these abhorrences there and started making it looks like a Buzzfeed page.