[GIFFER] Easy way to make a gif with MPV player

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

[GIFFER] Easy way to make a gif with MPV player

#1 Post by fabrice_035 »

Hi,
I am not the author but I would like to share the trick!

The trick is here : https://github.com/defaultxr/giffer

Code: Select all

# giffer
Easily make gifs or videos from a/b loop points in MPV.

This is a script to easily generate a gif or video file from the a/b loop points in MPV. I started from the code on http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html and modified it to work better with mpv, as well as have a few minor changes.

Technically, MPV is optional since you can easily use the script by itself in the shell.

# Requirements

- [mpv](https://mpv.io/) (video player; optional)
- ffmpeg (to actually generate the gif)
- bc (to calculate the duration from a/b start/end points; not optional if you want frame precision since bash's built-in `expr` command doesn't support floating point)

# Setup

- Add the lines in input.conf to your mpv's input.conf file (usually located at ~/.config/mpv/input.conf; create it if it doesn't exist already)
- Change the paths in those lines to point to the location where you put the 'giffer' script, and the location where you want the gif/video to be saved.

# Usage

- Play a video file using MPV.
- Press `l` to set the start point of the gif.
- Press `l` again to set the end point of the gif.
- After the start and end points have been defined, press `g` to export as gif or `h` to export as video.
- Press `l` a third time to clear the loop and continue watching the video.
- For extra precision, you can pause the video and then use `.` and `,` to move forward or backward by one frame.
if necessary you can modify the giffer script, line 25 and change

Code: Select all

filters="scale=320:-1,fps=$fps,scale=iw*sar:ih:flags=lanczos"
(just add scale=320:-1 to reduce size)

and necessarily modify the paths in input.conf

Bonne route ! Have a nice trip!

Image
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

Post Reply