1
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 5 years have passed since last update.

ffmpegで2つのgifファイルを1つにまとめる(左右に配置)

Last updated at Posted at 2019-12-06

はじめに

  • ffmpegを使って、2つのgifを1つにまとめる.
  • この記事では一旦mp4の形式に変換してgifに戻すやり方をする.(gif⇒mp4⇒gif)
  • 最終的にはgifの形式で出力する.
  • ffmpegのインストールは前の記事で書いたのでそちらを参照

実行環境

今回試した環境は以下の通りです.
OS: Ubuntu 18.04 LTS
CPU: i3-4130 3.40GHz
メモリ: 16GB

1. gif⇒mp4<変換>

以下のコードでgifからmp4に変換することができます.

$ ffmpeg -i input.gif -pix_fmt yuv420p output.mp4

以下の2つは適宜変更してください.

  • input.gif: 入力するgifファイル
  • output.mp4: 出力されるmp4ファイル

2. 2つのmp4ファイルを左右に配置

以下のコードで2つのmp4ファイルを左右に配置して1つのmp4ファイルとして出力してくれます.

$ ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4

以下の3つは適宜変更してください.

  • left.mp4: 入力するmp4ファイル(こちらが左側になる)
  • right.mp4: 入力するmp4ファイル(こちらが右側になる)
  • output.mp4: 出力されるmp4ファイル

3. mp4⇒gif<再変換>

以下のコードでmp4からgifに変換することができます.
※-r:フレームレート(以下のコードでは10と設定)

$  ffmpeg -i input.mp4 -r 10 output.gif

以下の2つは適宜変更してください.

  • input.mp4: 入力するmp4ファイル
  • output.gif: 出力されるgifファイル

まとめ

  • ffmpegで2つのgifを1つにまとめた.
  • だいたいffmpegで解決できるから本当に助かる.

参考文献

GIF アニメーションを mp4 ファイルへ変換する
【ffmpeg】 比較動画の作り方
FFmpegで動画をGIFに変換

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