1
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 1 year has passed since last update.

ffmpegでパラパラ動画を作成する際の画像ファイルの指定方法

Posted at

静止画像からパラパラ動画を作成するのためにffmpegを使用しました。ffmpegで入力ファイルを指定する際にちょっとつまずいたので、解決方法を記載します。

入力ファイルは「DSC_1804.JPG」から始まる516枚のJPGファイルで、連番になっています。
01.png

これをffmpegで動画化する際のコマンドは次のとおりです。
詳しくはffmpegで連番画像から動画生成 / 動画から連番画像を生成 ~コマ落ちを防ぐには~FFmpegで連番画像から動画を作成する際のTIPSなどが参考になります。

基本の設定

ffmpeg -r 30 -i DSC_%04d.JPG -vcodec libx264 -pix_fmt yuv420p out.mp4
  • -r フレームレートを指定します。
  • -i 入力ファイルを指定します
  • -vcodec コーデックを指定
  • -pix_fmx ピクセルフォーマットを指定

動画に詳しくないので一つ一つのオプションの意味はあまりわかっていないのですが、とりあえず一般的な動画はこれでうまくいくはずです。

-iオプションの入力画像の指定は「DSC_xxxx.JPG」というファイル名なので「%04d」で4桁の連番を読み込むように指定します。

なのですが、以下のようなエラーメッセージが出てしまいます。

[image2 @ 0x55bc1ae7d7c0] Could find no file with path 'resize/DSC_%03d.JPG' and index in the range 0-4
resize/DSC_%03d.JPG: No such file or directory

開始画像を指定する。

-i DSC_%4d.JPGオプションは0000からの連番を意味するようです。そのため「DSC_1804.JPG」から始まる今回のケースではNo such file or directoryのエラーが出てしまったようです。解決するためには-start_numberオプションを指定して、開始画像番号を明示します。

ffmpeg -r 30 -start_number 1804 -i DSC_%04d.JPG -vcodec libx264 -pix_fmt yuv420p out.mp4

これで、無事にパラパラ動画が出力されるようになりました。

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