VideoHelp Forum




+ Reply to Thread
Results 1 to 4 of 4
  1. 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
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    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.cmd
    Code:
    @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
    Cheers.


    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.
    Quote Quote  
  4. Originally Posted by pcspeak View Post
    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.cmd
    Code:
    @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
    Cheers.


    EDIT: 2/01/24 - Minor changes to the batch file to add a colon and delete a 'greater than' symbol.

    Pcspeak, I am so sorry.

    I forgot to mention that I only have access to an android device at the moment.

    Thank you so much for the help. Your script looks awesome.

    Sorry again
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!