3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ffmpeg で画像ファイルに文字入れ、グレースケール化等の画像処理をする ヽ(゚ー゚*ヽ)(ノ*゚ー゚)ノわぁい

Last updated at Posted at 2014-11-11

ffmpeg使ってますか?本当に便利で、こんなツールがオープンソースで無料で使えるなんて夢みたいです :smile: みんなはばりばり使いこなしちゃってると思うけど、今日はかわった使い方を紹介するよ :smiley:

画像ファイルも動画 :tv: ファイルもそんなに違いは無いよね。ffmpeg といえば『動画ファイルの加工』って感じ、画像ファイル加工するために、imagemagickとか入れるのもなーと思ってffmpegでどこまでできるかやってみたよ。

できることはわかってたんだけど、注意点もあるから時間があったら読んでみてね :smile:

:dog: :dog:

ffmpeg で画像に文字 :ab: を書いてみた

画像に文字を書いたりもできたよ :thumbsup: ↓のコマンド感じで 1.txt にある文字列を赤い文字、白いボーダーつけた新しい画像を作成する ffmpeg コマンドがこれ。1.txt に日本語書くならUTF-8にしようね :smile:

コマンド

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してもできないです。いや、たぶん、出来てるんだけ透明だから見えていないっていう落ちだと思う :tractor:

じゃあ、次 :traffic_light:

画像をグレースケールにしてみた

全く問題無くできるよ。windows で評判の悪い colorchannelmixer も、pngファイルに対しては問題無く期待通りの結果がでたよ :thumbsup:

コマンド

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
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?