Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active August 27, 2022 18:36
Show Gist options
  • Save mamemomonga/b9688c180ff78edd8582374e87f8f4c6 to your computer and use it in GitHub Desktop.
Save mamemomonga/b9688c180ff78edd8582374e87f8f4c6 to your computer and use it in GitHub Desktop.
オーディオを動画にするスクリプト
#!/bin/bash
set -eu
# フォントの関係でmacOS専用
if [ -z "${1:-}" ]; then
echo "USAGE:"
echo " $0 [AUDIO FILE]"
echo ""
exit 1
fi
SRCFILE=$1
DSTFILE=$(perl -E '$_="'$SRCFILE'"; s!\.(.+)$!.mp4!; say')
exec ffmpeg \
-f lavfi -y -i color=size=640x360:duration=1:rate=1:color=blue \
-i "$SRCFILE" \
-map 0:v -map 1:a \
-vf "drawtext=fontfile=/System/Library/Fonts/HelveticaNeue.ttc:fontsize=30:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text='Audio Only'" \
-ab 160k \
"$DSTFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment