ffmpeg使ってますか?本当に便利で、こんなツールがオープンソースで無料で使えるなんて夢みたいです みんなはばりばり使いこなしちゃってると思うけど、今日はかわった使い方を紹介するよ
画像ファイルも動画 ファイルもそんなに違いは無いよね。ffmpeg といえば『動画ファイルの加工』って感じ、画像ファイル加工するために、imagemagickとか入れるのもなーと思ってffmpegでどこまでできるかやってみたよ。
できることはわかってたんだけど、注意点もあるから時間があったら読んでみてね
ffmpeg で画像に文字 を書いてみた
画像に文字を書いたりもできたよ ↓のコマンド感じで 1.txt にある文字列を赤い文字、白いボーダーつけた新しい画像を作成する ffmpeg コマンドがこれ。1.txt に日本語書くならUTF-8にしようね
コマンド
ffmpeg -i sample.png -filter_complex "drawtext=fontsize=20:fontfile=yourfontfile.ttf:fontcolor=#FF0000:bordercolor=white:borderw=5:x=0:y=10:textfile=1.txt" -y text.png
注意点
もとになる画像がPNGの場合、透明部分にdrawtextしてもできないです。いや、たぶん、出来てるんだけ透明だから見えていないっていう落ちだと思う
じゃあ、次
画像をグレースケールにしてみた
全く問題無くできるよ。windows で評判の悪い colorchannelmixer も、pngファイルに対しては問題無く期待通りの結果がでたよ
コマンド
ffmpeg -i sample.png -filter_complex "colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3" -y grayscale.png
上下反転
コマンド
ffmpeg -i sample.png -filter_complex "vflip" -y vflip.png