VideoHelp Forum

+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Hi,
    I'd like to learn how to transform this (ffmpeg command) :

    ffmpeg -c:v h264_cuvid -i 891.mkv -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 891-x265.mkv

    AND this (cmd command) :

    "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language fr --priority lower --output ^"C:\Users\kngw\Desktop\test\891-x265-finished.mkv^" --language 0:ja --display-dimensions 0:1920x1080 --chroma-siting 0:1,2 --color-range 0:1 --language 1:fr --default-track-flag 1:no --language 2:ja --default-track-flag 2:yes --sub-charset 3:UTF-8 --language 3:fr --track-name 3:Forced --default-track-flag 3:no --sub-charset 4:UTF-8 --language 4:fr --track-name 4:Full --default-track-flag 4:yes ^"^(^" ^"C:\Users\kngw\Desktop\testo\891-x265.mkv^" ^"^)^" --title "" --track-order 0:0,0:2,0:1,0:4,0:3

    into a batch file.
    I can execute the two commands in a row for this file, it is working.
    But I'd like to use these two commands to make a batch in order to take all the files in a folder called "Original" which is composed of 1033 videos named "1.mkv" up to "1033.mkv" and to execue both commands on these, then put them on a "Export" folder.
    (Currently these commands put the new files in the same folder, so I need to make a batch file which export to another folder)

    I'm a newbie so maybe it's easy, I don't really know how everything works.
    Quote Quote  
  2. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Still asking.
    Quote Quote  
  3. Video Damager VoodooFX's Avatar
    Join Date
    Oct 2021
    Location
    At Doom9
    Search PM
    Check if this works:
    Code:
    for /R D:\Original %%i in (*.mkv) do ffmpeg -c:v h264_cuvid -i %%i -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 "%%~pi%%~ni-x265.mkv"
    Quote Quote  
  4. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Originally Posted by VoodooFX View Post
    Check if this works:
    Code:
    for /R D:\Original %%i in (*.mkv) do ffmpeg -c:v h264_cuvid -i %%i -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 "%%~pi%%~ni-x265.mkv"
    It is working! However, how to do the second part of the code in this batch file?
    Thanks.
    Quote Quote  
  5. Try this - create the .cmd file, place a shortcut for it on the desktop, and then just drag&drop input files on it (but set ffmpeg path properly)

    Code:
    @echo off
    SETLOCAL ENABLEEXTENSIONS
    set t0=%TIME%, %DATE%
    
    for %%F in (%*) do call :main %%F
    goto finalmessage
    
    :main
     SetLocal
      echo -----------------------------------------------------------------------------------
      echo. Processing file: %~f1
      echo.
      set "newdir=Export"
      if not exist "%~dp1\%newdir%" mkdir "%~dp1\%newdir%"
    
     " ffmpeg path here" -c:v h264_cuvid -i "%~f1" -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 "%~dp1\%newdir%\%~n1-x265.mkv"
    
     "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language fr --priority lower --output "%~dp1\%newdir%\%~n1-x265-finished.mkv" --language 0:ja --display-dimensions 0:1920x1080 --chroma-siting 0:1,2 --color-range 0:1 --language 1:fr --default-track-flag 1:no --language 2:ja --default-track-flag 2:yes --sub-charset 3:UTF-8 --language 3:fr --track-name 3:Forced --default-track-flag 3:no --sub-charset 4:UTF-8 --language 4:fr --track-name 4:Full --default-track-flag 4:yes "%~dp1\%newdir%\%~n1-x265.mkv" --title "" --track-order 0:0,0:2,0:1,0:4,0:3
      
     EndLocal
     goto :eof
    
    :finalmessage
    powershell write-host -fore cyan  ======================== Processing is FINISHED =========================
    echo ----------------------------
    echo Batch processing start time: %t0%
    echo Batch processing end time:   %TIME%, %DATE%
    echo ----------------------------
    pause
    Quote Quote  
  6. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Originally Posted by buzz1891 View Post
    Try this - create the .cmd file, place a shortcut for it on the desktop, and then just drag&drop input files on it (but set ffmpeg path properly)

    Code:
    @echo off
    SETLOCAL ENABLEEXTENSIONS
    set t0=%TIME%, %DATE%
    
    for %%F in (%*) do call :main %%F
    goto finalmessage
    
    :main
     SetLocal
      echo -----------------------------------------------------------------------------------
      echo. Processing file: %~f1
      echo.
      set "newdir=Export"
      if not exist "%~dp1\%newdir%" mkdir "%~dp1\%newdir%"
    
     " ffmpeg path here" -c:v h264_cuvid -i "%~f1" -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 "%~dp1\%newdir%\%~n1-x265.mkv"
    
     "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language fr --priority lower --output "%~dp1\%newdir%\%~n1-x265-finished.mkv" --language 0:ja --display-dimensions 0:1920x1080 --chroma-siting 0:1,2 --color-range 0:1 --language 1:fr --default-track-flag 1:no --language 2:ja --default-track-flag 2:yes --sub-charset 3:UTF-8 --language 3:fr --track-name 3:Forced --default-track-flag 3:no --sub-charset 4:UTF-8 --language 4:fr --track-name 4:Full --default-track-flag 4:yes "%~dp1\%newdir%\%~n1-x265.mkv" --title "" --track-order 0:0,0:2,0:1,0:4,0:3
      
     EndLocal
     goto :eof
    
    :finalmessage
    powershell write-host -fore cyan  ======================== Processing is FINISHED =========================
    echo ----------------------------
    echo Batch processing start time: %t0%
    echo Batch processing end time:   %TIME%, %DATE%
    echo ----------------------------
    pause
    I don't know how I can thank you, it's fabulous !! Thank you very much, it's working perfectly.
    Quote Quote  
  7. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Originally Posted by kngw View Post
    Originally Posted by buzz1891 View Post
    Try this - create the .cmd file, place a shortcut for it on the desktop, and then just drag&drop input files on it (but set ffmpeg path properly)

    Code:
    @echo off
    SETLOCAL ENABLEEXTENSIONS
    set t0=%TIME%, %DATE%
    
    for %%F in (%*) do call :main %%F
    goto finalmessage
    
    :main
     SetLocal
      echo -----------------------------------------------------------------------------------
      echo. Processing file: %~f1
      echo.
      set "newdir=Export"
      if not exist "%~dp1\%newdir%" mkdir "%~dp1\%newdir%"
    
     " ffmpeg path here" -c:v h264_cuvid -i "%~f1" -c:v hevc_nvenc -map 0 -rc vbr -cq 29 -qmin 29 -qmax 29 -tag:v hvc1 "%~dp1\%newdir%\%~n1-x265.mkv"
    
     "C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language fr --priority lower --output "%~dp1\%newdir%\%~n1-x265-finished.mkv" --language 0:ja --display-dimensions 0:1920x1080 --chroma-siting 0:1,2 --color-range 0:1 --language 1:fr --default-track-flag 1:no --language 2:ja --default-track-flag 2:yes --sub-charset 3:UTF-8 --language 3:fr --track-name 3:Forced --default-track-flag 3:no --sub-charset 4:UTF-8 --language 4:fr --track-name 4:Full --default-track-flag 4:yes "%~dp1\%newdir%\%~n1-x265.mkv" --title "" --track-order 0:0,0:2,0:1,0:4,0:3
      
     EndLocal
     goto :eof
    
    :finalmessage
    powershell write-host -fore cyan  ======================== Processing is FINISHED =========================
    echo ----------------------------
    echo Batch processing start time: %t0%
    echo Batch processing end time:   %TIME%, %DATE%
    echo ----------------------------
    pause
    I don't know how I can thank you, it's fabulous !! Thank you very much, it's working perfectly.
    However, if I don't want to keep the "-x265" files (not the one with -finished), how can I edit the code to delete them ? Or at least put them on a "Temporary" subfolder ?
    Last edited by kngw; 30th Sep 2022 at 03:35.
    Quote Quote  
  8. I don't want to keep the "-x265" files (not the one with -finished), how can I edit the code to delete them
    Just add suitable command to the end of main block:
    Code:
    "mkvtoolnix string ...."
    del "%~dp1\%newdir%\%~n1-x265.mkv"
    here %~dp1 - path to the input file, %newdir% - variable for the output folder, %~n1 - input file name
    Quote Quote  
  9. Member kngw's Avatar
    Join Date
    Sep 2022
    Location
    Paris
    Search PM
    Originally Posted by buzz1891 View Post
    I don't want to keep the "-x265" files (not the one with -finished), how can I edit the code to delete them
    Just add suitable command to the end of main block:
    Code:
    "mkvtoolnix string ...."
    del "%~dp1\%newdir%\%~n1-x265.mkv"
    here %~dp1 - path to the input file, %newdir% - variable for the output folder, %~n1 - input file name
    Thanks a lot, it works perfectly!
    Quote Quote  



Similar Threads