Hello everyone,
Is it possible to combine multiple scripts into one in ffmpeg?
What I am trying to do is create one master script that changes commands based on the aspect ratio of the input video.
For example, if the input video is closest to a 16:9 aspect ratio, ffmpeg will automatically convert the video using script "A".
If the input video is closest to a 4:3 aspect ratio, ffmpeg will automatically convert the video using script "B".
Finally, if the input video has a strange aspect ratio, (for example, cell phone videos) ffmpeg will automatically convert the video using script "C".
I am new to ffmpeg and do not understand much. If possible, will you please give a script that I can simply copy and paste into ffmpeg?
I already have scripts A, B, and C ready.
Also, as a side question, can you command ffmpeg to delete the original input video after successfully converting it?
Thanks everyone
+ Reply to Thread
Results 1 to 4 of 4
-
-
You can probably do some script although if/then will be purely based on operating system environment - ffmpeg offer some limited command support but they are rather low level type.
First you need to analyze your source then store result of analysis (trough system variable or externally in file) - later you can use result to perform if/then and do proper processing by calling ffmpeg with desired options. -
To get you started. Put your scripts, A, B, C, below the relevant labels and test.
You need https://mediaarea.net/download/binary/mediainfo/23.11.1/MediaInfo_CLI_23.11.1_Windows_x64.zip
Nothing gets deleted.... yet!
test01.cmdCode:@echo off for %%a in ("*.mp4", "*.avi", "*.mkv", "*.mpg", "*.ts") do call :get-dar "%%a" goto :end :get-dar set video=%~1 echo Getting the Display Aspect Ratio of %video% "C:\MediaInfoCLI\mediainfo.exe" "--Inform=Video;%%DisplayAspectRatio/String%%" "%video%" > ~tmpfile.txt set /p dar= < ~tmpfile.txt del ~tmpfile.txt if %dar% equ 16:9 call :A "%video%" if %dar% equ 4:3 call :B "%video%" if %dar% equ 2.35:1 call :C "%video%" if %dar% equ 2.40:1 call :D "%video%" goto :eof :A echo ffmpeg -i "%video%" %dar% goto :eof :B echo ffmpeg -i "%video%" %dar% goto :eof :C echo ffmpeg -i "%video%" %dar% goto :eof :D echo ffmpeg -i "%video%" %dar% goto :eof :end pause
EDIT: 2/01/24 - Minor changes to the batch file to add a colon and delete a 'greater than' symbol.Last edited by pcspeak; 1st Jan 2024 at 12:51.
-
Similar Threads
-
Help with guidance on Avisynth scripts
By Traderbam in forum Video ConversionReplies: 25Last Post: 23rd Jan 2024, 12:49 -
ffmpeg 5.0 new syntax breaks scripts, especially QSV
By BartZLederman in forum User guidesReplies: 6Last Post: 29th Mar 2022, 13:39 -
What is a good way to practice using AVISynth and FFMPEG scripts?
By Guernsey in forum Newbie / General discussionsReplies: 1Last Post: 28th Apr 2021, 12:51 -
Incorporate Avisynth Scripts into FFMPEG issues
By rgia in forum Newbie / General discussionsReplies: 43Last Post: 1st Jun 2020, 09:21 -
Need help Using MKVpropedit Scripts, or JMKVpropedit
By AManOfCharacter in forum EditingReplies: 5Last Post: 12th Apr 2020, 11:14