快乐大脚游戏规则:Making an album sampler video on the command line

March 31st, 2015. Tagged: ffmpeg, Music, tools

Here's a video I made to raise awareness about Anaconda Limousine's first album (where I play guitar and co-wrote 1 song): https://www.youtube.com/watch?v=0LavyKbSuvI. This is a post that explains how it was made so if anyone wants to made a similar one, they can have something to step on.

Turns out videos like this are called "album sampler" and there are quite a few of those

Input and goals

You start with:

  1. an image, the album cover
  2. all the songs, say in WAV format

The goal is to create a video that has the image as a background and also the title of each song. The audio for the video is 1 minute of each song starting somewhere from the middle. When you click each title, the video jumps forward to the part of the video that has this song as a background. The last step must be done manually in youtube using the annotation feature but all the rest is command-line.

Here's what the end result should look like (annotations not working in Firefox)

Prerequisites

I'm assuming an out-of-the-box Mac. You're on your own on other OSs.

You will need:

  1. Homebrew (to install the other pre-requisites)
  2. ImageMagick (for some light image manipulation)
  3. Sox (cutting pieces of songs and fade in/out)
  4. ffmpeg (to make the video)

Installing 'brew:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

ImageMagick (install and test):

$ brew install imagemagick

$ convert -version
Version: ImageMagick 6.9.0-10 Q16 x86_64 2015-03-08 //www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC

Sox:

$ brew install sox

$ sox -h

ffmpeg:

$ brew install ffmpeg

$ ffmpeg -version
ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers

The image

Starting with a cover image, scanned from the CD if you don't have the original, The CDs are pretty square:

anaconda

Let's use imagemagick to make it more video-dimensions friendly, meaning 16:9 ratio. My image happened to be 1200px, so keeping the height 1200px and the width becomes 1200 * 16 / 9 = 2133

We'll have the CD cover still in the center and fill the rest of the image with blackness:

# 1200x1200 to 16:9 ratio with black background
$ convert anaconda.jpg -background black -gravity center -extent 2133x1200 anaconda2.jpg

Result:

anaconda-16_9

After some manual typing of the track names (in Preview app) we get:

anaconda2

Not the prettiest, but it will have to do.

Audio

Say I have all the 9 wav files, ripped from the CD, in a ./wav directory. I need a loop that takes each file in this directory and runs it through Sox. In the past I've used ffmpeg to cut pieces of audio files, but turns out Sox can do it too and the best part is - it can also fade in and fade out so the previews are not abruptly cut.

Here's the loop:

$ i = 1; for f in wav/*; do sox "$f" "out/$((i++)).wav" trim 0:30.0 60 fade h 0:3 0 0:4; done

Now in ./out directory I have files 1.wav, 2.wav and so on... Each of these is a 1-minute slice, starting from the 30th second of the song. It fades in for 3 seconds and starts to fade out 4 seconds before the end of the one-minute piece.

Last audio step: make one file that is a concatenation of all 9 pieces:

$ sox out/1.wav out/2.wav out/3.wav out/4.wav out/5.wav out/6.wav out/7.wav out/8.wav out/9.wav all.wav

Video

The last step before uploading to youtube is to take the static image (anaconda2.jpg) and the background audio (all.wav) and make a video with ffmpeg:

$ ffmpeg -loop 1 -i anaconda2.jpg -i all.wav -r 1 -shortest anaconda.avi

That's all folks - the result is anaconda.avi ready for youtube and the millions of fans hungry for new music.

YouTube

After you upload the video, you have "Annotations" option, which doesn't work in Firefox, boo-hooo!

There are 5 ways to annotate, the one I liked the most is called "Spotlight".

Annotations can show up and then disapear, but you don't want that, so you make'em last throughout the video.

Make them transparent.

Make them link to the same video (0LavyKbSuvI in my case) and have the second song (link, annotation) go to minute 1 of the video, the next one to minute 2 and so on.

A little trick many people oversee is to make the first track go to 0:01 (1 second in), as opposed to the very beginning, because clicks on that link reload the video page otherwise.

Screen Shot 2015-03-31 at 12.35.59 AM

Thanks for reading!

... and happy album sampling!

Tell your friends about this post: Facebook, Twitter, Google+

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov


  • 76人参加高山滑雪跨界跨项选材测试 或进冬奥备战梯队 2019-05-18
  • 不是特效!上港队长一脚踢中海鸥 这脚法简直坑爹 2019-05-08
  • 新疆坚决打好污染防治攻坚战 2019-05-07
  • 高考在即,晋中市招生考试管理中心提醒广大考生及家长要把握好高考“四个趋势” 2019-04-25
  • 运城市在长三角招商引资149.9亿元 2019-04-08
  • 济南五胞胎雪虎宝宝亮相 四雌一雄萌态十足 2019-04-08
  • 去产能迎年中考 煤炭、钢铁企业债务问题依然存在 2019-04-07
  • 最高检等四部门出台意见 指导依法办理恐怖活动和极端主义犯罪案件 2019-04-07
  • 广州市黄埔区人民法院公告专栏 2019-03-28
  • 这个“海之宁”是个死抱着相对论旧谬误不放,疯狂反对科学新真理的跳梁“小丑”,这个跳梁“小丑”根本就不懂得尊重客观事实及其规律,总是无视、脱离、歪曲客观... 2019-03-22
  • 如何理解孔子这句话?北大教授胡军动情论生死 2019-03-21
  • 海外舆论关注中国最新军备 称赞习近平主席强军号令 2019-03-19
  • 女性之声——全国妇联 2019-03-19
  • 美司法部科米在希拉里邮件门调查中存在过失 2019-03-17
  • “四新”彰显党的十九大思想灵魂和精髓要义 2018-08-17
  • 714| 583| 253| 195| 736| 412| 994| 107| 137| 708|