All entries for Monday 02 July 2012
July 02, 2012
A long time ago, in a
galaxy street far not all that far away, there is a nightclub I visited on N occasions. You might know it as Kasbah because you're much younger than I am and don't remember when it was called The Colosseum. Anyway, it had a big screen at one end that showed random video clips of a few seconds each. Bits of cartoons, the Enterprise D going to warp, all sorts of things. For reasons that completely escape me I started thinking about that recently and wondering how easy it would be to make a video sequence like that. I have no practical use for such a thing, but it seemed like an interesting exercise.
So if you've been wondering how you can easily create a video that comprises randomly selected clips then this is the blog post for you. To create such a video you will need:
- One computer running a Unix-like Operating System. (I tested on Mac OS X 10.6 and openSUSE 12.1)
- Lots of video. The more video you have, the more random (for a given value of random) the clips will be.
- A copy of ffmpeg compiled with libx264 support. If you're using a Mac I highly recommend you have MacPorts installed or be prepared to hack the script a bit to make it work.
- Script that mashes up videos which you save in to a directory on it's own and then run. It will plunder your video collection and assemble a montage of random clips of total length defined by a variable in the script (default is 60 seconds). The number of clips and length of each clip varies on each run.
You'll want to read the comments at the start of the script before running it. The output is 1280x720 H.264 encoded in an mp4 container. Aspect ratios are not preserved. Any video clip from a source with an aspect ratio that isn't 16:9 will be stretched to 16:9. I did consider preserving aspect ratio but doing so would have meant that some clips had back bars either side of them and some wouldn't. That would be visually jarring. The output has no sound because it would be horrible if it had sound. I did try adding sound but it went hopelessly out of sync with the video and I couldn't be bothered figuring out making that work.
Ideally there would be a sample of the output here. In practise there isn't because of concerns about licenses, credits and all that sort of stuff.