VideoHelp Forum
+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. is there a way to automate the output filename in a regular ".bat" ?

    I sometimes do things like adding audio tracks from another video, keep the audio of the original and change the container such as:

    Code:
    "%FFMPEG%" -i "C:\Test\Video1.mp4"  -i "C:\Test\Video2.mp4"  -map 0:v:0 -map 1:a:1 -map 0:a:1 -c:v copy -c:a copy -f matroska "C:\Test\Video-NEW.mkv"
    which adds an audio track from a different video to the first video as the first audio track, keeps the original audio as a second track and changes the container to mkv.

    I would love to automate the output command so that I only have to use one command for the output which just uses the input filename as an output filename (for example Video1.mp4.mkv) instead of specifying the output path and filename every time.

    Of course drag and drop cmd isn't an option for this because you can't drag 2 or even more files into a "cmd" at the same time and expect it to know which -i comes when.

    Is there a clever command for this? I read through all kinds of threads such as

    https://forum.videohelp.com/threads/398507-Top10-Commands-for-Lossless-Video-manipulat...e)#post2592949
    https://github.com/butterw/bShaders/blob/master/test_LimitedRange/ffm4b.bat
    https://manpages.ubuntu.com/manpages/xenial/en/man1/ffmpeg.1.html
    https://forum.videohelp.com/threads/399797-FFMpeg-Auto-output-Name-on-bat-Script-file

    but they are all only refering to the drag and drop / cmd way "%FFMPEG%" -i %INPUTFILE%

    which suggests


    %1%.mp4
    "%~dpnx1.mp4"
    "%%~nf_New.mp4"

    I tried those in my bat but they usually just let it create a ".mkv" file with no output name at all.
    Quote Quote  
  2. Member
    Join Date
    Aug 2006
    Location
    United States
    Search Comp PM
    I have a template for ffmpeg batch files.
    You can manipulate the output filename (in quotes). Play around with it.



    Code:
    REM -
    mkdir Recode
    
    for %%a in ("*.mkv") do call :my_function "%%a"
    pause
    exit
    
    :my_function
    
    ffmpeg -i "%~1" -map 0 -vcodec copy -scodec copy -acodec ac3 -b:a 384k "Recode\%~n1.mp4"
    
    goto :eof
    Quote Quote  
  3. Code:
    set f_name=bla_bla_bla
    "%FFMPEG%" -i "C:\Test\%f_name%.mp4"  -i "C:\Test\Video2.mp4"  -map 0:v:0 -map 1:a:1 -map 0:a:1 -c:v copy -c:a copy -f matroska "C:\Test\%f_name%.mkv"
    Quote Quote  
  4. thanks I think I got it now -)
    Quote Quote  



Similar Threads

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