Skip to content

Commit

Permalink
FFmpeg Automations
Browse files Browse the repository at this point in the history
While working on exporting my songs' videos with FFmpeg for my newly-releasing Flatlands album, I made some updates to the original Bash script that I used to export each song last time. Now it can do all of the songs for me, in one go! The script will iterate over each thumbnail in my folder which has all of the thumbnails made from this project, and it will take that image path, and get the source song WAV file from the parent directory up (that's how I structure my music folders, this can be any path setup that you'd like), and it runs FFmpeg with these two files, and produces the result MP4 file, and places it right next to the thumbnail. Then I can upload the videos for each song up to YouTube, and voila! This is working very well already, and I really happy with it now.

So the main changes for this file update is that the script can run this for each song file for you, you don't have to do it manually. It has also moved over to opening WAV files instead of M4A ones, as I am more aware of trying to keep the best quality of the song now. This also means that the WAV file has to be reencoded to AAC with FFmpeg, rather than just being copied as-is from the source M4A file, which already is AAC. I also moved the 'pix_fmt' option into the 'vf' 'format' option instead, as this appears to behave the exact same way. I found someone else doing this on Reddit, and it does seem a little more convenient/straightforward.

On an unrelated note, I just installed Rust for the first time on my new machine! This will be my first time trying it out. I still don't know what I'm doing in Rust yet, so I'm going to be looking into it off-and-on just to dip my toes into the ecosystem a little bit more. I think it will be a great additional next step of something to have in my toolchain.
  • Loading branch information
Offroaders123 committed Apr 7, 2023
1 parent 93dda9b commit 38aed1b
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions test/ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
ffmpeg \
-loop 1 \
-framerate 1 \
-i "26.png" \
-i "26.m4a" \
-map 0 \
-map 1:a \
-c:v libx264 \
-preset ultrafast \
-tune stillimage \
-vf scale=out_color_matrix=bt709,fps=10 \
-pix_fmt yuv420p \
-c:a copy \
-shortest \
"26.mp4"
for thumbnail in ./*.png
do
name=$(basename -s .png "$thumbnail")
audio="../$name.wav"
video="./$name.mp4"

# Debug
# echo $thumbnail
# echo $name
# echo $audio
# echo $video
# echo ""

ffmpeg \
-loop 1 \
-framerate 1 \
-i "$thumbnail" \
-i "$audio" \
-map 0 \
-map 1:a \
-c:v libx264 \
-preset ultrafast \
-tune stillimage \
-vf "scale=out_color_matrix=bt709,fps=10,format=yuv420p" \
-c:a aac \
-shortest \
"$video"
done

0 comments on commit 38aed1b

Please sign in to comment.