Resize and convert jpg/mp4 to bmp/gif using FFmpeg

To resize and convert jpg to bmp/mp4 to gif using FFmpeg.


Download and Install FFmpeg on Windows 11

1. Download FFmpeg
Go to the official FFmpeg download page (https://www.ffmpeg.org/download.html).
Get packages & executable files.
Choose a trusted Windows build provider (e.g., gyan.dev).
Download the archive ffmpeg-git-essentials.7z (this version is lightweight and sufficient for most users).
Extract the archive to a folder, for example:
    C:\ffmpeg\

2. Set Environment Variable PATH
1. In Windows search, type “Environment Variables” and open Edit the system environment variables.
2. In the “System Properties” window, click Environment Variables….
3. In the User variables section, find Path → click Edit.
4. Add a new entry:
    C:\ffmpeg\bin
5. Save and close.

3. Test Installation
Open Command Prompt (CMD) or PowerShell, then type:
ffmpeg -version


Resize and convert jpg to bmp

Convert all .jpg files in the current folder into 240×240 BMP images, and place them neatly into a BMP subfolder:

convert_jpg_to_bmp.bat (default RGB888)
@echo off
REM Batch script to convert all JPG files in the current folder to BMP
REM Output BMPs will be scaled to 240x240
REM All BMPs will be saved into a subfolder called "BMP"

REM Create BMP folder if it does not exist
if not exist "BMP" (
    mkdir "BMP"
)

for %%a in (*.jpg) do (
    echo Converting %%a ...
    ffmpeg -i "%%a" -vf scale=240:240 "BMP\%%~na.bmp"
)

echo All conversions finished! BMPs are in the "BMP" folder.
pause
By default, ffmpeg save bmp in RGB888 formmat. To specify format, use -pix_fmt option.

-pix_fmt rgb24   → RGB888 (default, 24‑bit BMP)
-pix_fmt rgb565 → RGB565 (16‑bit BMP, 5 bits red, 6 bits green, 5 bits blue)

Convert all .jpg files in the current folder into 240×240 BMP in RGB565 images, and place them neatly into a BMP565 subfolder:

convert_jpg_to_bmp_565.bat
@echo off
REM Batch script to convert all JPG files in the current folder to BMP
REM Output BMPs will be scaled to 240x240
REM All BMPs will be saved into a subfolder called "BMP"

REM Create BMP folder if it does not exist
if not exist "BMP565" (
    mkdir "BMP565"
)

for %%a in (*.jpg) do (
    echo Converting %%a ...
    ffmpeg -i "%%a" -vf scale=240:240 -pix_fmt rgb565 "BMP565\%%~na_565.bmp"
)

echo All conversions finished! BMPs are in the "BMP565" folder.
pause


Resize and convert mp4 to animated gif.

Quick method
ffmpeg -i input.mp4 -vf scale=240:240 -r 15 output.gif
Explanation
-i input.mp4 → input file
-vf scale=240:240 → resize to 240×240
-r 15 → reduce frame rate to 15 fps
output.gif → output fil

Here’s a ready‑to‑use Windows batch file (.bat) that will automatically convert all .mp4 
files in the current folder into .gif files, scaled to 240×240 and reduced to 10 fps,
and place the results neatly into a GIFs subfolder.

convert_mp4_to_gif.bat
@echo off
REM Batch script to convert all MP4 files in the current folder to GIF
REM Output GIFs will be scaled to 240x240 and set to 10 fps
REM All GIFs will be saved into a subfolder called "GIFs_10"

REM Create GIFs folder if it does not exist
if not exist "GIFs_10" (
    mkdir "GIFs_10"
)

for %%a in (*.mp4) do (
    echo Converting %%a ...
    ffmpeg -i "%%a" -vf scale=240:240 -r 10 "GIFs_10\%%~na_10.gif"
)

echo All conversions finished! GIFs are in the "GIFs_10" folder.
pause


Extra: Sort-by-name and rename files, place in "new_folder" sub-folder.

Example:
rename.bat xyz abcde

Sort all files with extention xyz, and rename abcde_000.xyz, abcde_001.xyz..., save in "new_folder" sub-folder.

rename.bat
@echo off
REM rename.bat - Sort files by name and rename with numbering
REM Usage:
REM   rename para1
REM   rename para1 para2
REM   para1 must be exactly 3 characters (file extension)

:: If no parameters, show usage
if "%~1"=="" (
    echo Usage:
    echo   rename para1
    echo   rename para1 para2
    echo   para1 is limited to 3 characters ^(file extension^).

    echo   Example: rename mp4
    echo            rename mp4 video
    goto :eof
)

:: First parameter = extension
set "ext=%~1"

:: Check length of extension (must be 3)
if not "%ext%"=="" (
    if "%ext:~3,1%"=="" (
        REM ok, length is 3
    ) else (
        echo Error: para1 must be exactly 3 characters ^(file extension^).
        goto :eof
    )
)

:: Second parameter = basename (optional)
if "%~2"=="" (
    set "basename=%ext%"
) else (
    set "basename=%~2"
)

:: Create new_folder if it does not exist
if not exist "new_folder" (
    mkdir "new_folder"
)

setlocal enabledelayedexpansion
set /a count=0

:: Process files sorted by name
for /f "delims=" %%f in ('dir /b /o:n *.%ext%') do (
    set "num=000!count!"
    set "num=!num:~-3!"
    copy "%%f" "new_folder\%basename%_!num!.%ext%" >nul
    set /a count+=1
)

echo Done! Renamed all .%ext% files sorted by name into "new_folder".
pause



Comments

Popular posts from this blog

Drive 320x240 ILI9341 SPI TFT using ESP32-S3 (NodeMCU ESP-S3-12K-Kit) using TFT_eSPI library, in Arduino Framework.

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library