Last active
February 6, 2021 14:51
-
-
Save KiaraGrouwstra/c5cbb5445c3e25f4c1cd8d195e904574 to your computer and use it in GitHub Desktop.
creating a video from an image plus audio files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumptions: audio files in .flac, no other flac files, named alphabetically | |
# cut to part of a recording | |
ffmpeg -ss mm:ss -to mm2:ss2 -i in.flac -codec copy out.flac | |
# replace a segment | |
ffmpeg -to mm:ss -i in.flac -codec copy pre.flac; ffmpeg -ss mm2:ss2 -i in.flac -codec copy post.flac; ffmpeg -f concat -safe 0 -i <( for f in {pre,replacement,post}.flac; do echo "file '$(pwd)/$f'"; done ) -c copy out.wav; flac out.wav; rm pre.flac; rm post.flac; rm out.wav | |
# get chapter timestamps for youtube | |
for song_file in *.flac; do echo $song_file; done | |
duration=0; total=0; rounded=$total; hours=0; mins=0; secs=0; for song_file in *.flac; do rm -f tmp.wav; echo "$hours:$(printf "%02d\n" $mins):$(printf "%02d\n" $secs)"; flac -d -o tmp.wav $song_file > /dev/null 2>&1; duration=`soxi -D tmp.wav`; total=`echo "$total + $duration" | bc`; rounded=`printf "%.*f\n" "" "$total"`; hours=`expr $rounded / 3600`; mins=$((`expr $rounded / 60` - $hours * 60)); secs=$(($rounded - $hours * 3600 - $mins * 60)); done; rm -f tmp.wav | |
# concatenate audio files | |
ffmpeg -f concat -safe 0 -i <( for f in *.flac; do echo "file '$(pwd)/$f'"; done ) -c copy audio.flac | |
# restore metadata | |
sox audio.flac audio_.flac --show-progress | |
# # denoise audio | |
# sox audio.flac -n noiseprof noise_profile_file | |
# sox audio.flac audio_denoised.flac noisered noise_profile_file 0.31 | |
# video | |
# svg to image | |
inkscape -w 2580 -h 1470 -y 1 logo.svg --export-filename logo.png | |
# preferably use youtube's 16:9 aspect ratio i.e. 1.777~ | |
magick logo.png -resize 1025x577 -background white -compose Copy -gravity center -extent 1025x577 -quality 92 youtube.png | |
# video from image + audio | |
ffmpeg -stream_loop -1 -r 1 -i youtube.png -i audio_.flac -vcodec h264 -shortest -q:v 5 video.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment