How do I make a music video?





If you have comments or suggestions, click here.

Q. I've made some drawings and I have a short sound file where I play the guitar. Is there a free Linux way to combine the drawings and the sound file to make a music video?

A. If you're comfortable with Linux CLI and the GIMP, yes.

Requirements: Linux, the GIMP, ffmpeg (most releases from the past year or two should work), at least 10 drawings, and a sound file that's at least 20 seconds long.

1. If the drawings are on paper, the first step is to scan them and produce image files. Use PNG format if possible but JPEG is O.K. If JPEGs are used, set the JPEG quality factor to somewhere between 89 and 92.

2. Use the GIMP to crop and/or resize the image files so that they're all the same dimensions.

Note: Larger is better, up to a point, but any dimensions from 320x240 to 1280x1024 are O.K. If the images are larger than 1280x1024, consider scaling them down.

3. Rename the files and give them number-based names similar to this:

myvideo-0001.jpg  myvideo-0002.jpg  myvideo-0003.jpg  etc.

In other words, the filenames should consist of a word, followed by a dash, followed by four digits, followed by a period and the filename extension. Replace jpg (shown here) with the appropriate filename extension.

The numbers should be assigned in the same order that you wish the drawings to appear in your music video.

4. Determine the length (in seconds) of the sound file. To do this, use an ffmpeg command similar to the following:

ffmpeg -i guitar.wav 2>&1 | grep -i duration

Replace guitar.wav with the sound-file name (or pathname).

5. Take the total number of images, subtract one, and divide the result by the sound-file length (in seconds). We'll call this the “FPS number”.

If the FPS number is less than 0.20, stop here. In this case, you need more images or a shorter sound clip.

6. Make a shell script that contains commands similar to the following. The backslashes are required. Make sure there's no white space after the backslashes.

Modify the four parameters appropriately. Additionally, replace jpg with the appropriate image filename extension.


#!/bin/sh
BASENAME=myvideo        # Word that starts the image-file names
OUTFILE=output.mp4      # MP4 output-file name (or pathname)
RATE=0.415              # FPS number computed previously
SOUNDFILE=guitar.wav    # Sound input-file name (or pathname) 

ffmpeg -y -r $RATE \
    -i "$BASENAME-%04d.jpg" \
    -i $SOUNDFILE \
    -vcodec libx264 -acodec libmp3lame \
    $OUTFILE

7. Run the script. If it works, the MP4 file specified by OUTFILE should be created.

8. Try playing the MP4 file. Both mplayer and vlc should work.

If the pictures end too soon (relative to the sound track), decrease the RATE setting in the script slightly and go to step 7.

If the sound track ends too soon (relative to the pictures), increase the RATE setting in the script slightly and go to step 7.




For anybody who's curious, here's a sample frame from a music video based on the correspondent's files:

Picture

And here's the video itself on YouTube. You'll need Flash and a fast Internet connection to play this:






Hosting provided by Zymic.

For acknowledgments related to CSS and other code used, click here.

Linked or embedded works (software, books, articles, etc.) are presented under their own licenses.

Other unique content on this page, excluding screenshots, is distributed under the following license: C.C. Attribution NonCommercial ShareAlike 3.0. In some cases, screenshots are distributed under the same license. In other cases, the associated program's license applies.

Technical note: This page can't be W3C-validated at present due to the use of an embedded YouTube video.