%20%22else%22%20%EB%B3%80%ED%98%95%EB%8F%84%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4(Windows%20%EB%B0%B0%EC%B9%98%20%ED%8C%8C%EC%9D%BC)..png)
특정 nVidia 파일이 있으면 그래픽 카드를 사용하여 비디오를 인코딩하는 배치 파일에서 명령을 생성하려고 합니다. 하지만 해당 nVidia 파일이 없으면 다른 명령을 사용하기 위해 다른 레이블로 건너뜁니다.
:SOFTWARE_ENCODE
nvcuda.dll이 다음 위치에 없으면 레이블 로 건너뛰지 않습니다 .
if exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :NVIDIA_ENCODE
if not exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :SOFTWARE_ENCODE
nvcuda.dll이 존재하는 경우 위의 작업이 작동하고 :NVIDIA_ENCODE
레이블로 건너뜁니다.
나는 주위를 둘러보며 누군가가 else
괄호를 사용하여 문제를 해결하는 것을 보았지만 그것도 작동하지 않습니다.
if exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" (goto NVIDIA_ENCODE) else goto SOFTWARE_ENCODE
동일한 결과가 발생합니다. nvcuda.dll이 없으면 나머지 배치 파일을 건너뛰는 것 같습니다.
if exist
nVidia 인코딩과 소프트웨어 인코딩이 모두 비디오 인코딩에 작동한다는 것을 알고 있습니다. 및 부분 을 주석 처리하고 if not exist
각(ffmpeg) 인코딩 명령을 개별적으로 테스트했기 때문입니다.
(소프트웨어 인코딩을 테스트할 때 nvcuda.dll의 이름을 ".bak"로 바꿉니다).
goto
나는 과거에 이런 일이 일어난 것을 기억하며 와 함께 사용하면 왜 무시하는지 전혀 모릅니다 if not exist
.
모든 솔루션에 크게 감사드립니다.
편집: 전체 배치 파일은 다음과 같습니다.
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
:: ------------------------------------------------------------------------------
:: This part swaps the first and last 4 characters around...
:: (This processes all files in sub-folders, but I want to make it only process files next to the batch file)...
setlocal enabledelayedexpansion
echo.
for /f "delims= eol=:" %%f in ('dir /b /a-d G???????*.* ????G???*.*') do (
set filename=%%~nf
set firstfour=!filename:~0,4!
set secondfour=!filename:~4,4!
echo %%f ^> !secondfour!!firstfour!!filename:~8!%%~xf
ren %%f !secondfour!!firstfour!!filename:~8!%%~xf
)
set /a Index=1
:: ------------------------------------------------------------------------------
:: This part renames the files 001, 002, 003 and so on.
for /r %%i in (*.mp4) do (
rem if number is less than 10, append 9 to file name
if !Index! lss 10 (
rename "%%i" 00"!Index!.mp4"
) else (
rename "%%i" "0!Index!.mp4"
)
set /a Index+=1
)
:: ------------------------------------------------------------------------------
:: Delete junk files...
del "*.LRV"
del "*.THM"
:: ------------------------------------------------------------------------------
rem Create TEMP folder for files to be created in...
if not exist "TEMP" md "TEMP"
:: ------------------------------------------------------------------------------
:: Use nVidia to encode if that driver file is installed...
:: Not working, but will work if nvcuda.dll is there...
:: if exist %SYSTEMDRIVE%\Windows\System32\nvcuda.dll (goto NVIDIA_ENCODE) else goto SOFTWARE_ENCODE
:: Original lines also not working...
if exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :NVIDIA_ENCODE
if not exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :SOFTWARE_ENCODE
:: ------------------------------------------------------------------------------
:: Convert to 1080p...
:NVIDIA_ENCODE
rem Convert video files...
FOR /F "tokens=*" %%G IN ('dir /b *.mp4') DO start /wait /min ffmpeg.exe -y -i "%%G" -vcodec hevc_nvenc -vf scale=1920:-2,fps=23.976 -b:v 4000k -acodec aac -b:a 192k -ar 44100 -ac 2 "TEMP\%%~nG.mp4" -hide_banner
goto :JOIN_FILES
:SOFTWARE_ENCODE
rem Convert video files...
FOR /F "tokens=*" %%G IN ('dir /b *.mp4') DO start /wait /min ffmpeg.exe -y -i "%%G" -vcodec libx265 -vf scale=1920:-2,fps=23.976 -b:v 4000k -acodec aac -b:a 192k -ar 44100 -ac 2 "TEMP\%%~nG.mp4" -hide_banner
goto :JOIN_FILES
:: ------------------------------------------------------------------------------
:: Join the files into one video...
:JOIN_FILES
(for %%i in (TEMP\*.mp4) do @echo file '%%i') > mp4_file_list.txt
For %%a IN ("TEMP\*.mp4") DO Set "mp4file=%%~na"
start /wait /min ffmpeg.exe -y -f concat -safe 0 -i mp4_file_list.txt -c copy "%mp4file%_JOINED.mp4" -hide_banner
del mp4_file_list.txt
:: ------------------------------------------------------------------------------
:: Delete the TEMP folder...
rd /s /q "TEMP\"
:: ------------------------------------------------------------------------------
:: Rename the "*_JOINED.mp4" file with todays date and " - GoPro Video" at the end.
:: (The dating method follows the format: YYYY-MM-DD) [May not work on non-UK systems]
For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%b-%%a)
ren "*_JOINED.mp4" "%mydate% - GoPro Video.mp4"
:: Create a folder "Converted Video" and move the newly converted video file to it.
if not exist "Converted Video" md "Converted Video"
MOVE /Y "%mydate% - GoPro Video.mp4" "Converted Video"
:: ------------------------------------------------------------------------------
:: Rename any old files back to mp4 again that got moved/renamed at the start...
for /r %%x in (*.S6C8JHVH2E7L4BX9) do ren "%%x" *.mp4
:: ------------------------------------------------------------------------------
:: Open folder with finished video...
explorer "Converted Video"
:: ------------------------------------------------------------------------------
exit
폴더에 MP4를 넣어서 이 프로그램을 단독으로 실행하면 제대로 작동합니다.
:: ------------------------------------------------------------------------------
:: Use nVidia to encode if that driver file is installed...
if exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :NVIDIA_ENCODE
if not exist "%SYSTEMDRIVE%\Windows\System32\nvcuda.dll" goto :SOFTWARE_ENCODE
:: ------------------------------------------------------------------------------
:: Convert to 1080p...
:NVIDIA_ENCODE
rem Convert video files...
FOR /F "tokens=*" %%G IN ('dir /b *.mp4') DO start /wait /min ffmpeg.exe -y -i "%%G" -vcodec hevc_nvenc -vf scale=1920:-2,fps=23.976 -b:v 4000k -acodec aac -b:a 192k -ar 44100 -ac 2 "TEMP\%%~nG.mp4" -hide_banner
goto :JOIN_FILES
:SOFTWARE_ENCODE
rem Convert video files...
FOR /F "tokens=*" %%G IN ('dir /b *.mp4') DO start /wait /min ffmpeg.exe -y -i "%%G" -vcodec libx265 -vf scale=1920:-2,fps=23.976 -b:v 4000k -acodec aac -b:a 192k -ar 44100 -ac 2 "TEMP\%%~nG.mp4" -hide_banner
goto :JOIN_FILES
:: ------------------------------------------------------------------------------
:JOIN_FILES
exit
사용해 보았 pause
으나 소용이 없었습니다.