0
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 3 years have passed since last update.

画面収録ファイル(mov)からgifを作成

Last updated at Posted at 2022-02-13

これは何?

Qiita等へ投稿する際に、画面の様子をアップしたい時に、画面のgifをさくっと作成するためのワークフローです。

環境は、以下のとおりです。

  • MacBook Pro (13-inch, 2019, Four Thunderbolt 3 ports)
  • Darwin monju.local 21.2.0 Darwin Kernel Version 21.2.0
  • ffmpeg: stable 4.4.1 (bottled)

概要

手順は、以下のとおりです。

  1. 画面収録
  2. ffmpegを使用して、ファイルを変換

画面のとりこみ

Shift + Command + 5

を押すと、選択範囲の画面を収録することができます。
私の場合、保存先をデスクトップにしています。

ffmpegにてgifの作成

保存されたファイルを、ffmpegを使って変換します。
こちらのスクリプトを拝借します。

gifenc.sh
# !/bin/bash

palette="/tmp/palette.png"

filters="fps=15,scale=640:-1:flags=lanczos"

ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse=dither=floyd_steinberg"  -y $2

使用方法は、以下のとおりです。
sl.movが、収録した画面のファイルです。

$ chmod +x gifenc.sh
$ ./gifenc.sh sl.mov sl.gif

以下の、gifが作成されました。

sl.gif

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