Convert APNG to MP4/GIF/WEBM using FFMPEG

If you miss your old GIF/WEBM/MP4 format

Last Update: 2025-09-11

Instruction

Make a new text file, paste the code below, and save it with a ".bat" extension (i.e revert.bat)

Make sure you have FFMPEG installed: https://www.ffmpeg.org/download.html

Code to paste (v0.1)

@echo off
setlocal enabledelayedexpansion

:: Save the current directory
set "currentDir=%~dp0"
set /a count=0

echo APNG to GIF/MP4/WEBM Conversion v0.1
echo A simple script that will automatically convert ALL PNG to GIF/MP4/WEBM using FFMPEG in the CURRENT FOLDER
echo Current Folder: %currentDir%
echo( 
echo Please select which filetype you want the APNG to be converted into
echo 1) GIF
echo 2) MP4 
echo 3) WEBM 
echo(
CHOICE /M Select /C 123

If Errorlevel 3 Goto 3
If Errorlevel 2 Goto 2
If Errorlevel 1 Goto 1

:1
cls
call :convertGIF
Goto end

:2
cls
call :convertMP4
Goto end

:3
cls
call :convertWEBM
Goto end


:: Convert all PNG into GIF
:convertGIF
echo(
echo Converting APNG to GIF...
echo(
for %%f in ("%currentDir%*.png") do (
    echo Converting %%~nxf ...
    ffmpeg -hide_banner -loglevel error -i "%%~nxf" -vf "scale='if(gt(iw,ih),200,-1)':'if(gt(iw,ih),-1,200)':flags=lanczos,split [a][b];[a] palettegen=stats_mode=diff [p];[b][p] paletteuse=dither=none" -f gif -plays 0 "%%~nf.gif"
    set /a count+=1
)
EXIT /B


:: Convert all PNG into MP4
:convertMP4
echo(
echo Converting APNG to MP4...
echo(
for %%f in ("%currentDir%*.png") do (
    echo Converting %%~nxf ...
    ffmpeg -hide_banner -loglevel error -i "%%~nxf" -vf "fps=10, scale='if(gt(iw,ih),200,-1)':'if(gt(iw,ih),-1,200)':flags=lanczos,split [a][b];[a] palettegen=stats_mode=diff [p];[b][p] paletteuse=dither=none" -f mp4 -plays 0 "%%~nf.mp4"
    set /a count+=1
)
EXIT /B


:: Convert all PNG into WEBM
:convertWEBM
echo(
echo Converting APNG to WEBM...
echo(
for %%f in ("%currentDir%*.png") do (
    echo Converting %%~nxf ...
    ffmpeg -hide_banner -loglevel error -i "%%~nxf" -vf "fps=8, scale='if(gt(iw,ih),200,-1)':'if(gt(iw,ih),-1,200)':flags=lanczos,split [a][b];[a] palettegen=stats_mode=diff [p];[b][p] paletteuse=dither=none" -f webm -plays 0 "%%~nf.webm"
    set /a count+=1
)
EXIT /B


:end
echo(
echo Conversion completed, %count% file converted
pause
start "" "%currentDir%"
exit
Edit

Pub: 11 Sep 2025 00:44 UTC

Edit: 11 Sep 2025 00:45 UTC

Views: 13