Last active
April 13, 2023 12:20
-
-
Save iUltimateLP/73d1e5a127b4fc7e617002bcb88da2b6 to your computer and use it in GitHub Desktop.
Extracts a number of images sequentially aligned in a horizontal strip of slides into seperate files (e.g. for Instagram Slides). Requires FFMPEG!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Check for arguments | |
IF [%1]==[] GOTO USAGE | |
IF [%2]==[] GOTO USAGE | |
IF [%3]==[] GOTO USAGE | |
:: Arguments | |
SET "input=%1" | |
SET "inputName=%~n1" | |
SET "outputDir=%2" | |
SET /A slideCount=%3 | |
:: Remove quotation marks | |
SET input=%input:"=% | |
SET inputName=%inputName:"=% | |
SET outputDir=%outputDir:"=% | |
:: Run ffmpeg | |
echo Extracting %slidecount% slides from "%input%" to "%outputDir%" | |
:: FFMPEG using the crop video filter (syntax is crop=w:h:x:y, iw and ih are "image width" and "image height") | |
"ffmpeg.exe" -loop 1 -i "%input%" -vf "crop=iw/%slideCount%:ih:n*(iw/%slideCount%):0" -vframes %slideCount% "%outputDir%/%inputName%_%%02d.png" | |
GOTO :EOF | |
:: Wrong usage | |
:USAGE | |
echo Invalid arguments! | |
echo Usage: | |
echo "%0" "<input file>" "<output dir>" ^<slide count^> | |
exit /B 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment