24
18

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 のエラー "width not divisible by 2" への対処

Last updated at Posted at 2018-10-05

##環境
・Ubuntu 16.04
・ffmpeg 3.4

ffmpegは以下でインストールできる
参考サイト

$ sudo add-apt-repository ppa:jonathonf/ffmpeg-3
$ sudo apt update && sudo apt upgrade
$ sudo apt install ppa-purge && ppa-purge ppa:jonathonf/ffmpeg-3

##問題のエラー

ffmpegでimage_0000.jpgから始まる連番画像を動画に変換する際に現れたエラー

$ ffmpeg -r 12 -i image_%04d.jpg -vcodec libx264 -pix_fmt yuv420p -r 24 out.mp4

実行するとエラーが出る

width not divisible by 2 (993x758)

縦、横の各ピクセル数が2の倍数でないのが原因

ピクセル数を2の倍数に変換

以下のオプションを追記すれば良い

-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

オプションを追加して実行

$ ffmpeg -r 12 -i image_%04d.jpg -vcodec libx264 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -r 24 out.mp4

変換に成功した

24
18
1

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
24
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?