Re: Generate "automagic" music videos with ffmpeg & friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That is a really nice ffmpeg command! Good stuff!

On Thu, Oct 20, 2016 at 9:33 AM, Yassin Philip <philcm@xxxxxxx> wrote:

Hi Listers!

Here is a little tooly that I made that may be be of any use to you guys ;

Today, 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 that kind of things now.

Back on topic : You don't have time to put together a proper video for your shiny new because you have a life and recording the song already took the best of it lately.

Here is a script to quickly generate a cool-looking music video, given the sound file, the cover artwork image and an optional ending bit :

#!/usr/bin/env bash

FILE_PATH="$1"
FFMPEG="ffmpeg"
ARTIST="$2"
ALBUM="$3"
COVER_FILE_PATH="$4"
EFFECT="$5"

if [ "$#" -ne 5 ]; then
    echo "Usage: $0 [audio file path] 'artist name' 'album name' [artwork image file path] [point|line|p2p|cline]"
    exit
fi

convert -resize 1280x720 "${COVER_FILE_PATH}" -background none -gravity center -extent 1280x720 "${COVER_FILE_PATH}.jpg"

$FFMPEG -y -i "${FILE_PATH}" -loop 1 -i "${COVER_FILE_PATH}.jpg" -filter_complex "[0:a] showwaves=s=1280x310:mode=${EFFECT}:r=25,colorkey=0x000000:0.1:0.5[wave];[1:v][wave] overlay=y=H-h:eval=init[canvas];[canvas]drawtext=fontfile='Jura-Book.ttf':fontsize=60:text='${ARTIST}':x=30:y=(h-70-text_h*2.5):fontcolor=white:shadowy=2:shadowx=2:shadowcolor=black,drawtext=fontfile='Jura-Book.ttf':fontsize=72:text='${ALBUM}':x=20:y=(h-70-text_h):fontcolor=ff6600:shadowy=2:shadowx=2:shadowcolor=black" -shortest -codec:v libx264 -crf 18 -preset fast -codec:a aac -strict -2 -b:a 192k "${FILE_PATH}-composite.mp4"

if [[ -e "end.mp4" ]]; then
    $FFMPEG -y -i "${FILE_PATH}-composite.mp4" -i "end.mp4" -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" "${ARTIST}-${ALBUM}.mp4"

    rm -rf "${FILE_PATH}-composite.mp4"
else
    mv "${FILE_PATH}-composite.mp4" "${ARTIST}-${ALBUM}.mp4"
fi

rm -rf "${COVER_FILE_PATH}.jpg"

echo -e "
################################################
DONE : ${ARTIST}-${ALBUM}.mp4"

This will
  • Take the (PNG) cover, and center it inside a 1280x720 (AKA 720p) pixels video ;
  • Generate a "wave" of the (WAV) sound file ;
  • Print "Artist" in Orange, And then "Title" in White, below, slightly bigger and offset to the left ;
  • 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.

Notes:

  • This script depends on the ffmpeg and imagemagick packages
  • The last argument is the style of the dancing waveform, take a short audio file to experiment with all 4 of them
  • The "end.mp4" file is optional, it's there if you want an ending credit / legal / whatever bit, or a nice fade out, anything. It's scaled to fit.
  • 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.
With it, you can make that kind of music video ; hope it's useful, cheers everybody, keep on rocking it!


yPhil

-- 
Yassin "xaccrocheur" Philip
http://manyrecords.com / http://yassinphilip.bitbucket.org

_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-user


_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux