2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Mac】.movを.gifに自動変換する

Last updated at Posted at 2025-03-28

はじめに

Macの画面収録ってmovファイルになると思うのですが、毎回gifに変換するのが面倒だな〜と思っていたところ今回良いやり方を見つけたので共有します!

n番煎じ感が否めないですが、どなたかのお役に立てれば...!!!

やりたいこと

  • 任意のフォルダ(例:screenshot)に .mov を追加すると自動で同じフォルダに .gif が生成される
  • ファイル名はそのまま(例:sample.movsample.gif

macにはAutomatorなるアプリがプリインストールされているみたいで(初めて知った)、そのフォルダアクションって機能を使ったら実装できそうだったので使ってみました!

事前準備

ffmpeg のインストール
movをgifに変換するためのライブラリです

brew install ffmpeg

フォルダアクションの作成(Automator)

1. Automator を起動

  • 「アプリケーション」 > Automator

↓こいつ
スクリーンショット 2025-03-27 15.38.32.png

2. 新規作成 → 「フォルダアクション」を選択

スクリーンショット 2025-03-27 15.37.55.png

3. アクション「シェルスクリプトを実行」を追加

スクリーンショット 2025-03-27 15.40.04.png

4. 対象のフォルダを選択

「その他」から選択できます

スクリーンショット 2025-03-27 15.40.40.png

5. 入力の引き渡し方法:「引数として渡す」

スクリーンショット 2025-03-27 15.41.26.png

6. 以下のスクリプトをコピペ:

for f in "$@"
do
  if [[ "$f" == *.mov ]]; then
    dir_path="$(dirname "$f")"
    base_name="$(basename "$f" .mov)"
    out_path="${dir_path}/${base_name}.gif"
    
    /opt/homebrew/bin/ffmpeg -i "$f" -r 24 "$out_path"
  fi
done

ffmpeg のパスは環境によって変更必要な場合があります。
which ffmpeg で確認できます。

which ffmpegの結果を使ってコマンドを実行するのは無理でした :cry:

# ffmpegのパスを自動取得
ffmpeg_path="$(which ffmpeg)"

"$ffmpeg_path" -i "$f" -r 24 "$out_path"

7. 「cmd + S」で保存して完了

動作確認

画面収録 2025-03-27 15.26.58.gif

いい感じですね :tada:

おわりに

Qiitaにgifをはっつける時とか、プロジェクトでちょっとした動画を共有するのが少し楽になりましたね!
Automator今まで使ってこなかったですが、可能性を感じました!

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?