mpv-webp-avif-generator
May 1, 2026 · View on GitHub
A mpv user script to quickly generate animated WebP or AVIF clips from any video segment using FFmpeg.

Note: This script now supports both Windows and Linux.
For macOS, I do not have a test environment. Contributions are welcome!
Credits:
- Animation source: NASA/SVS
- Original author: https://github.com/DonCanjas/mpv-webp-generator
Features
- Export the currently set A-B loop as an animated WebP or AVIF.
- Output resolution, quality, and encoding options are configurable.
- Supports embedded and external subtitles. (Tested with SRT and ASS subtitles)
- Output files are automatically named and saved to your desktop (Windows) or home directory (Linux) by default.
Requirements
Quick Install (using Scoop, Windows only)
On Windows, you can easily install mpv and FFmpeg using Scoop:
scoop install mpv ffmpeg
Installation
- Download the script : mpv-webp.lua
- Place the script in your
scriptsdirectory:- Windows:
%APPDATA%\mpv\scripts\ - If you installed mpv with Scoop (Windows), the path is usually:
C:\Users\<YourUser>\scoop\apps\mpv\current\portable_config\scripts\ - Linux:
~/.config/mpv/scripts/
- Windows:
- Ensure FFmpeg is installed and available in your system PATH.
- Or edit the
ffmpeg_pathoption to point to your FFmpeg executable.
- Or edit the
Usage
- Set the A-B loop in mpv to mark the start (A) and end (B) of the segment you want to export.
- Press Ctrl+[ to set or clear point A, and Ctrl+] to set or clear point B.
- You can also use
lto set point A andlagain to set point B (default mpv key binding for A-B loop).
- Press Ctrl+w to generate an animated WebP.
- Press Alt+w to generate an animated AVIF.
A small dot will appear in the top-right corner while the export is in progress. The resulting file will be saved to your desktop (Windows) or home directory (Linux), or the directory set in the script options.
Options
You can configure these options in the webp.conf file located in your script-opts directory:
ffmpeg_path=ffmpeg # Path to ffmpeg executable
dir=~~desktop/ # Output directory (default: desktop on Windows, ~ on Linux)
libplacebo=no # libplacebo filter (yes = enable, no = disable)
rez=640 # Output width (pixels), keeps aspect ratio
fps=0 # 0 = use source video fps
max_fps=0 # Maximum output frame rate,0 = no limit
loop=0 # Animation loop count (0 = infinite)
lossless=0 # WebP: 0=lossy, 1=lossless
quality=90 # WebP: 0-100 (higher = better quality)
compression_level=5 # WebP: 0-6 (higher = smaller size, slower)
avif_quality=30 # AVIF: CRF value (lower = better quality)
avif_preset=3 # AVIF: encoding preset, 0-13 (lower is higher quality and slower)
libplacebo Option Explained
libplacebo=yes: Enables libplacebo filter in FFmpeg. This enables advanced features such as:
- Debanding
- Frame interpolation (e.g., 30fps → 60fps)
⚠️ Note: Using
libplaceborequires:
- Your FFmpeg build includes
libplacebowith frame_mixer support enabled and Vulkan support- If you installs FFmpeg via Scoop on Windows,it already includes libplacebo support.
- On Linux, you can download static-built FFmpeg which includes libplacebo from here: https://github.com/yt-dlp/FFmpeg-Builds/releases/tag/latest
Example config file locations:
- Windows:
%APPDATA%\mpv\script-opts\webp.conf - Scoop:
C:\Users\<YourUser>\scoop\apps\mpv\current\portable_config\script-opts\webp.conf - Linux:
~/.config/mpv/script-opts/webp.conf
You can change the default hotkeys by editing your input.conf file.
To do this:
- Find your
input.conffile:- Windows:
%APPDATA%\mpv\input.conf - Scoop:
C:\Users\<YourUser>\scoop\apps\mpv\current\portable_config\input.conf - Linux:
~/.config/mpv/input.conf
- Windows:
- Add or modify the following lines:
Ctrl+[ script-binding set_start_time
Ctrl+] script-binding set_end_time
Ctrl+w script-binding make_webp_from_abloop
Alt+w script-binding make_avif_from_abloop
This allows you to customize the hotkeys for setting start/end points and generating webp/avif to any key combination you prefer. See mpv input.conf documentation for more details.
Known Issues
- After closing mpv, any running ffmpeg processes started by this script will not automatically exit.
- If ffmpeg hangs or gets stuck, you will need to manually kill any running
ffmpegprocess.