Help us understand the problem. What is going on with this article?

動画操作ソフト ffmpeg のエラー "width not divisible by 2" への対処

More than 1 year has passed since last update.

環境

・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

変換に成功した

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした