0
0

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を使ったタイムラプス動画の作成したメモ

0
Last updated at Posted at 2024-12-02

ffmpegの詳細については割愛するが、ffmpeg公式ドキュメントから引用すると

A complete, cross-platform solution to record, convert and stream audio and video.
オーディオとビデオを記録、変換、ストリーミングするための完全なクロスプラットフォームソリューション。

とある。ビデオの変換を行えるこのツールを使って、タイムラプス動画を作成した。

30秒の動画ファイルのパスが複数記載されたファイル(ファイルの内容はこちらを参照。動画の合計時間は3時間分)を読み込んで、それを連結しながら1080倍速したwebmファイルを作成する場合、以下のコマンドを実行。

/usr/bin/ffmpeg -f concat -safe 0 -i input.txt -vf "setpts=PTS/1080" timelapse.webm

あまりに実行完了まで時間がかかるので途中で処理を中断。(15分ほど待機して中断)
品質はあまり重視していなかったので、品質を落として効率を優先するために-c:v libvpx-vp9 -quality realtime -speed 8オプションを追加。

libvpx-vp9 ... CPUによるvp9エンコード
-quality realtime -speed 8 ... 最も品質を落として効率を優先

/usr/bin/ffmpeg -f concat -safe 0 -i input.txt -vf "setpts=PTS/1080" -c:v libvpx-vp9 -quality realtime -speed 8 timelaps.webm

結果、3時間の動画を1080倍にする変換が約六分で完了するようになった。

余談だが、上記の場合CPUリソースをすべて使っていたため、tasksetコマンドで ffmpegプロセスに関連付けるコア数を制限した。

taskset -c 0-2  /usr/bin/ffmpeg -f concat -safe 0 -i input.txt -vf "setpts=PTS/1080" -c:v libvpx-vp9 -quality realtime -speed 8 timelaps.webm

参考

https://developers.google.com/media/vp9/live-encoding?hl=ja
https://ffmpeg.org/ffmpeg-filters.html
https://trac.ffmpeg.org/wiki/Encode/VP9#speed

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?