2
1

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.

Macでよく使うffmpegのメモ

Last updated at Posted at 2020-01-29

Macでよく使うffmpegのメモ

物忘れの激しい私がffmpegのパラメータまで覚えてるわけないのでメモる。

動画

MOVからMP4

デフォルトの設定だとQuickTime等で再生できないので-pix_fmt yuv420pをつける

$ ffmpeg -i in.mov -pix_fmt yuv420p  out.mp4

解像度変更

MacのRetinaディスプレイだと解像度大きすぎて送れない場合があるので容量を圧縮する

$ ffmpeg -i in.mp4 -vf scale=1920:-1  out.mp4

scale=xx:-1とすると動画のアスペクト比に合わせて変換される

GIFを作りたい

Qiitaとかに上げるときに使う技

$ ffmpeg -i in.mp4 -vf "palettegen" -y palette.png
$ ffmpeg -i in.mp4 -i palette.png -lavfi "fps=12,scale=900:-1:flags=lanczos [x]; [x][1:v] paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -y out.gif

カラーパレット生成を挟むことできれいなGIFになる

参考元:ffmpegで動画を綺麗なgifに変換するコツ

音声だけ抜く

本当はコーデック調べたりするべきだけど大体これ

$ ffmpeg -i in.mp4 -acodec copy out.m4a

画像

動画も、画像も、できるんだよ

リサイズ

$ ffmpeg -i in.png -vf scale=720:-1 -q 2  out.png

動画と同様にできる

-qオプションで圧縮レベルを指定できる。(1は-qmin 1 -q 1)

動画のスクリーンショット

$ ffmpeg -i in.mp4 -ss xxx -t yyy -r zzz out%d.png

-ss 開始時間(フレーム単位)

-t 終了時間(フレーム単位)

-r フレームレート

最後に

ffmpegは万能。

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?