Generate "automagic" music videos with ffmpeg & friends
In today's tutorial, we'll put the guitar down and talk about Libre Music video Production :)
Where is your video?
Recently, if you want to publish a song, pretty soon they're going to ask your for "the video". But sometimes you don't have the time / money to do it. Heck, it's a job. The "Lost Week" video took me like a (big. Huge) week to put together, not counting shooting time. BTW it was edited in KDEnlive, but since No Sister (and my Why, Phil show and all) I use Blender for video production now.
Back on topic : You don't have time to put together a proper video for your shiny new tune because you have a life and recording the song already took the best of it lately.
- Make sure you have both ffmpeg and imagemagick installed :
apt install ffmpeg imagemagick
- Create a directory, and get inside it
- Download this script by issuing this command :
- Then make it executable :
chmod +x yphil-video-maker.sh
Ok, so let's say our song is called "My Song" and that the audio file, mysong.wav, is located in your "Music/MyBand/MySong/" directory.
You want the real stuff, the fat PCM WAV of the full quality last mixdown, because it will be encoded (read : degraded) so you want to start with the best audio material available.
Now the cover artwork image. Same thing, you want the real, Full HD maximum-size-hires-straight-out-of-gimp version of the image you have, because it too will be compressed to bits. Let's say this image is named "cover.png" and lives in the same album's directory. The command you would have to enter to generate your video would then be :
./yphil-video-maker.sh ~/Music/MyBand/MySong/mysong.wav "My Band" "My Song" ~/Music/MyBand/MySong/cover.png line
Depending on the duration of the song, it can take a pretty long time ; A lot of things are happening right now. What the script does exactly is :
- Take the (in our example, a PNG file) cover, and center it inside a 1280x720 (AKA 720p) pixels video ;
- Generate a dancing wave of your (in our example, a WAV file) sound file ;
- Print "My Band" in Orange, And then "My Song" in White, below, slightly bigger and to the left ;
- Put a nice bottom-right offset drop shadow on all the letters so they "cut through the mix" so to speak
- Merge the 3 together ;
- If there exists a file named "end.mp4" in the directory, append it to the final video ;
- Clean up everything, and produce a file named "Artist-Title.mp4" in 720p.
The last argument (in our exemple "line" is the style of the dancing waveform, take a short audio file to experiment with all 4 of them : point, line, p2p, and cline.
The "end.mp4" file is optional, it's there if you want an ending credit / legal / whatever bit, or a nice fade out, anything, at the very end of your music video. It's scaled to fit. Oh, and If there is a "Jura-Book.ttf" font file in the directory from which the script is invoked, it will be used, otherwise your default serif font will be.
Of course, you are welcome to modify all this (Font family, font size, font color, text position) not just the image and sound, to make the video truly yours. Use the Libre Font Library Project website to download a public domain cool font TTF file.
You're a video prod unit too, now
That's it, you now have a file named "My Band-My Song.mp4" ready to upload, in HD720p. You can pat yourself in the back and send it to the interflubes for everybody to behold.