Skip to content

Instantly share code, notes, and snippets.

@ogra
Last active May 21, 2019 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogra/37665d303008e072b699e3a8fa686d90 to your computer and use it in GitHub Desktop.
Save ogra/37665d303008e072b699e3a8fa686d90 to your computer and use it in GitHub Desktop.
カレントディレクトリに置いた画像picture.png(ピクセル数は縦横ともに偶数)を使い、カレントディレクトリにあるaudioディレクトリにあるすべてのMP3ファイル(拡張子.mp3)をffmpegで動画に変換して、カレントディレクトリにあるvideoディレクトリにMP4ファイルとして保存するスクリプト
#!/usr/bin/env bash
for filename in ./audio/*.mp3; do
outputfile=`echo $filename | sed 's/^\.\/audio\//\.\/video\//' | sed 's/mp3$/mp4/'`
ffmpeg \
-loop 1 \
-r 30000/1001 \
-i picture.png -i $filename \
-vcodec libx264 \
-acodec aac -strict experimental -ab 320k -ac 2 -ar 44100 \
-pix_fmt yuv420p \
-shortest \
$outputfile
done
@ogra
Copy link
Author

ogra commented May 21, 2019

ffmpegの使い方は
https://dev.classmethod.jp/etc/ffmpeg-create-movie-by-audio/
を参考にしました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment