Making high quality animated topic thumbnails

You can make and use high quality videos that are still small enough to be a thumbnail:
bunny-360

Here’s a bat script to generate them:
ffmpeg-topic-preview.bat.txt (3.1 KB)
Place it together with ffmpeg.exe and the video and run

ffmpeg-topic-preview.bat big_buck_bunny_720p.mp4 30 20 40
Usage: ffmpeg-topic-preview.bat <input_video_file> <start_time> <duration> [quality] [effort]
Example: ffmpeg-topic-preview.bat "Big Buck Bunny.mp4" 00:00:30 20
Example: ffmpeg-topic-preview.bat "Big Buck Bunny.mp4" 00:00:30 20 50   (lower quality)
Quality: 0-63 (lower=better, default=40)
Effort: 0-12 (lower=slower/better, default=8)
Code
@echo off
setlocal EnableDelayedExpansion

REM Default values
set "RESOLUTION=360"
set "DEFAULT_QUALITY=40"
set "DEFAULT_EFFORT=8"

REM Parameter validation - if any required parameter is missing, show usage
if "%~1"=="" goto :show_usage
if "%~2"=="" goto :show_usage
if "%~3"=="" goto :show_usage

REM Process input parameters (remove quotes if present)
set "input=%~1"
set "start_time=%~2"
set "duration=%~3"

REM Set quality parameter with default
if "%~4"=="" (
    set "quality=%DEFAULT_QUALITY%"
) else (
    set "quality=%~4"
)

REM Set effort parameter with default
if "%~5"=="" (
    set "effort=%DEFAULT_EFFORT%"
) else (
    set "effort=%~5"
)

REM Generate output filename
set "output=%~n1-%RESOLUTION%p.avif"

REM Validate input file exists
if not exist "%input%" (
    echo ERROR: Input file "%input%" does not exist!
    pause
    exit /b 1
)

echo Converting "%input%" to "%output%"
echo Start time: %start_time%, Duration: %duration%s
echo Resolution: %RESOLUTION%p, Quality: %quality%, Effort: %effort%
echo.

REM FFmpeg command with parameter explanations:
REM -ss: Seek to start time (skip beginning)
REM -i: Input video file
REM -t: Duration in seconds to process
REM -vf "scale=-2:360": Video filter - scale to 360p height, auto width (even)
REM -c:v libsvtav1: Video codec - SVT-AV1 encoder
REM -crf: Quality 0-63 (lower=better quality, higher=smaller file)
REM -preset: Effort 0-12 (lower=slower encoding/better compression)
REM -an: Remove all audio streams
REM -loop 0: Infinite loop for AVIF animation
REM -y: Overwrite output file without prompting
echo ^> ffmpeg -ss "%start_time%" -i "%input%" -t "%duration%" -vf "scale=-2:%RESOLUTION%" -c:v libsvtav1 -crf %quality% -preset %effort% -an -loop 0 "%output%" -y

ffmpeg -ss "%start_time%" -i "%input%" -t "%duration%" -vf "scale=-2:%RESOLUTION%" -c:v libsvtav1 -crf %quality% -preset %effort% -an -loop 0 "%output%" -y

REM Check if output file was created
if not exist "%output%" (
    echo ERROR: Failed to create output file!
    pause
    exit /b 1
)

REM File exists, check size
for %%A in ("%output%") do set "filesize=%%~zA"
set /a filesizeKB=!filesize!/1024
echo.
echo File created: %output%
echo File size: !filesizeKB! KB

REM Check if file is too large
if !filesize! gtr 1000000 (
    echo.
    echo WARNING: File size exceeds 1000 KB!
    echo Images over 1MB can't be used as topic previews
    echo.
    set /a suggested_quality=%quality%+10
    if !suggested_quality! gtr 63 set suggested_quality=63
    echo Suggestions to reduce file size:
    echo - Increase quality value ^(current: %quality%, try e.g. !suggested_quality!^)
    echo - Reduce duration ^(current: %duration%s, try shorter clips^)
) else (
    echo File size is acceptable for use as topic preview.
)

pause
goto :eof

:show_usage
echo Usage: %~nx0 ^<input_video_file^> ^<start_time^> ^<duration^> [quality] [effort]
echo Example: %~nx0 "Big Buck Bunny.mp4" 00:00:30 20
echo Example: %~nx0 "Big Buck Bunny.mp4" 00:00:30 20 50 (lower quality)
echo Quality: 0-63 (lower=better, default=%DEFAULT_QUALITY%)
echo Effort: 0-12 (lower=slower/better, default=%DEFAULT_EFFORT%)
pause
exit /b 1

If you are not on Windows or don’t like running bat files, just run the exactly same ffmpeg command

ffmpeg -ss "00:00:30" -i "big_buck_bunny_720p.mp4" -t "20" -vf "scale=-2:360" -c:v libsvtav1 -crf 40 -preset 8 -an -loop 0 "big_buck_bunny_720p-360p.avif" -y

varying -ss (start), -t (duration) and -crf(quality) to make the file below 1MB

4 Likes

Bruh, I thought something nasty will happen in this preview, but you tricked me. Thanks for the batch though.

Cool so this can created moving images for under 1mb. Nice, but my god, this looks very advanced. Any chance it can be dumbed down a bit. Or point me some where to learn.

I tried command prompt:

ffmpeg -ss “00:00:30” -i “name of video and .mp4” -t “20” -vf “scale=-2:360” -c:v libsvtav1 -crf 40 -preset 8 -an -loop 0 “name of video again.avif” -y

Error

‘ffmpeg’ is not recognized as an internal or external command,

operable program or batch file.

:sob:
I can’t

https://www.kimi.com/ , https://grok.com/ or whatever the ChatGPT of the day is
Ask literally what you asked above

tl;dr first try winget install ffmpeg (win11 should have winget iirc) if that doesn’t work get it at Builds - CODEX FFMPEG @ gyan.dev

Hello, sorry to be a pain. I’m really keen to get this to work. I followed a youtube vidoe to install command prompt winget install ffmpeg. So I think that is done.

I took that bat script put into note pad and saved it in the same folder as the video.

I run command prompt it runs
C:\Users\kelvi\Documents>GIF Usage: Gif.bat [quality] [effort] Example: Gif.bat “Big Buck Bunny.mp4” 00:00:30 20 Example: Gif.bat “Big Buck Bunny.mp4” 00:00:30 20 50 (lower quality) Quality: 0-63 (lower=better, default=40) Effort: 0-12 (lower=slower/better, default=8) Press any key to continue . . .

‘’Place it together with ffmpeg.exe and the video and run’’

This bit I’m not getting. How does one place together ffmpeg and video.

Do I need to edit the last part of the bat script in note pad to get the conversion done?

If the name of my video is ‘’Eroscript’’

I do something like this:

echo Usage: ffmpeg-topic-preview.bat<input_video_file^> ^<start_time^> ^<duration^> [quality] [effort]
echo Example: ffmpeg-topic-preview.bat “Eroscript.mp4” 00:00:30 20
echo Example: ffmpeg-topic-preview.bat “Eroscript.mp4” 00:00:30 20 50 (lower quality)
echo Quality: 0-63 (lower=better, default=40)
echo Effort: 0-12 (lower=slower/better, default=8)
pause
exit /b 1