DigitalSignage – Free Video Slideshow – FFMPEG – Batch Script to Export JPG or PNG to MP4

The goal: take 100 .JPG or .PNG images, and export them to a video-slideshow as a MP4 container on a Windows computer.

This was way harder than I expected it to be without spending $60-100 on complex video editing software.¬† So many of the conversion guides require Linux or OSX to use the Blob (wildcard) feature for inputting file-names, but it doesn’t work on Windows.

I needed something simple enough I could give it to a common user, and get them creating video slideshows.

 

Here is my solution, hoping someone out there finds it helpful.

Get the binary for ffmpeg.exe from: https://www.ffmpeg.org/download.html and click the Windows Build download link.

The only file you will need from this ZIP is ffmpeg.exe.

Create a new folder on your desktop, copy in your images (.PNG or .JPG, whatever you’re converting), and copy in ffmpeg.exe.

Create a new text file and change the file extension to .BAT (Batch Script).

Pop in the following code.

::Import screenshots/photos, and export them into a MP4 to be uploaded for digital signage displays or other uses.

::This creates a "short-format" list of any .PNG files in a list by listing the files in a loop, and outputting to a text file called images.txt. If you need to adjust to .JPG or .GIF, edit below.
::The images.txt file will be fed into ffmpeg for processing of video files.
::If you ever need "long-format" (C:\Folder\image1.png vs image2.png) you can put /r after the "for" command.
for %%a in (*.PNG) do (
    echo file '%%a' >> images.txt
)
::This requires the file "ffmpeg.exe" be in the same directory as the photos
::Input Frame Rate - 0.1 frames per second = 1 image per 10 seconds. 
::File -- Add together the Input of images.txt
::Video Format - libx264 inside of a .mp4 container
::Output Video Frame Rate - 30fps (required for a lot of digital signage systems to actually process the video, don't worry, size doesn't increase very much)
::Name - File Name (NewVideo.mp4)
::Yes - Overwrite Prompt
ffmpeg.exe -r .1 -f concat -i images.txt -c:v libx264 -pix_fmt yuv420p -r 30 NewVideo.mp4 -y

::Deletes the images.txt format so images don't double-up.
del /q images.txt

::Waits for user input before closing the command prompt, to make sure everything runs propertly.
PAUSE

 

Leave a Reply

Your email address will not be published. Required fields are marked *