- Local time
- 1:03 AM
- Posts
- 331
- OS
- Windows 11
I have two separate scripts and both are working perfectly. The first one is my main script which chooses the windows power plan I want, then creates a folder called "Proxy" on my desktop and then encodes a video file and puts it in the proxy folder and once the job is done it will shutdown the PC unless I decide not to at the final prompt. It's working perfectly as intended.
The second script, runs mediainfo software to get video information (Hight and Width), then it uses this information to crop the video in the desired way and then it encodes the video. This script also works perfectly fine.
What I want to do is to have the cropping function (done in the second script) to also be added to the first script. I think what is needed is to have the 9 first lines of the second script added to the first one!
I hope I was able to express myself correctly!
Here is the first script:
And here is the second one:
The second script, runs mediainfo software to get video information (Hight and Width), then it uses this information to crop the video in the desired way and then it encodes the video. This script also works perfectly fine.
What I want to do is to have the cropping function (done in the second script) to also be added to the first script. I think what is needed is to have the 9 first lines of the second script added to the first one!
I hope I was able to express myself correctly!
Here is the first script:
Code:
@echo off
for /f "tokens=4 delims= " %%f in ('powercfg /getactivescheme') do (
set ACTIVE_SCHEME=%%f
)
powercfg /setactive 6ff28809-1a19-42c9-871d-92674ac92e45
setlocal EnableExtensions DisableDelayedExpansion
set "t0=%TIME%, %DATE%"
set "RestoreFolder="
set "ProxyDir=%USERPROFILE%\Desktop\Proxy"
if not exist "%ProxyDir%" mkdir "%ProxyDir%"
rem Is the batch file started without any argument (or with first argument
rem being an empty string)? Yes, process all video files in current directory.
if "%~1" == "" goto AllFiles
rem Is the batch file started not with a folder name as first argument?
rem Yes, the first argument is most likely a file name and so just a
rem single file should be processed by the batch file.
if not exist "%~1\" goto SingleFile
rem The batch file is started with a folder name as first argument.
rem Make this folder the current directory using command PUSHD and
rem if that is successfull process all video files in that folder.
pushd "%~1" 2>nul
if not errorlevel 1 set "RestoreFolder=1" & goto AllFiles
echo ERROR: Failed to make "%~1" the current directory!
echo/
pause
exit /B 1
:AllFiles
for %%i in (*.mp4 *.avi *.mov *.wmv *.ts *.m2ts *.mkv) do if not exist "%ProxyDir%\%%~ni_proxy.mp4" (
if /I not "%%~xi" == ".avi" (
"%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_proxy.mp4" --crop 0,0,3584,0 --output-res 960x-2 -c h264 --preset quality --cqp 23:25:28 --aq-strength 10 --ref 1 --bframes 0 --gop-len 15 --lookahead 15 --qp-max 30 --aq --cabac --mv-precision q-pel --avsync cfr --colorprim auto --transfer auto --colormatrix auto --colorrange auto
) else (
"%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_proxy.mp4" --crop 0,0,3584,0 --output-res 960x-2 -c h264 --preset quality --cqp 23:25:28 --aq-strength 10 --ref 1 --bframes 0 --gop-len 15 --lookahead 15 --qp-max 30 --aq --cabac --mv-precision q-pel
)
)
if defined Restorefolder popd
goto OutputInfo
:SingleFile
if exist "%~1" goto ProcessFile
echo ERROR: Could not find "%~1"!
echo/
pause
exit /B 1
:ProcessFile
if not exist "%ProxyDir%\%~n1_proxy.mp4" (
if /I not "%~x1" == ".avi" (
"%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_proxy.mp4" --crop 0,0,3584,0 --output-res 960x-2 -c h264 --preset quality --cqp 23:25:28 --aq-strength 10 --ref 1 --bframes 0 --gop-len 15 --lookahead 15 --qp-max 30 --aq --cabac --mv-precision q-pel --avsync cfr --colorprim auto --transfer auto --colormatrix auto --colorrange auto
) else (
"%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_proxy.mp4" --crop 0,0,3584,0 --output-res 960x-2 -c h264 --preset quality --cqp 23:25:28 --aq-strength 10 --ref 1 --bframes 0 --gop-len 15 --lookahead 15 --qp-max 30 --aq --cabac --mv-precision q-pel --avsync cfr
)
)
:OutputInfo
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe write-host -fore cyan ====================== Processing is FINISHED =======================
echo ----------------------------
echo Batch processing start time: %t0%
echo Batch processing end time: %TIME%, %DATE%
echo ----------------------------
endlocal
@ECHO OFF
powercfg /change standby-timeout-ac 20
:myLabel
SHUTDOWN /S /F /T 600
SET /P continue="Your computer is about to shutdown in 10 min do you want to abort (y/n): "
IF %continue% EQU y (
SHUTDOWN /A
)
And here is the second one:
Code:
"D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe" --inform=Video;%%Width%% "%~dpnx1" > "test.txt"
set /p width= < "test.txt"
"D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe" --inform=Video;%%Height%% "%~dpnx1" > "test.txt"
set /p height= < "test.txt"
del "test.txt"
set /a hwidth=%width%/2
set /a ewidth=%width%/16
set /a eheight=%height%/8
REM start /b /low "nvencc"
"D:\Software\Shared Programs Elitebook\!proxy generator\nvencc\NVEncC64.exe" -i "%~1" -o "%~dpn1.proxy.mp4" --crop 0,0,%hwidth%,0 --output-res 960x-2 -c h264 --preset quality --cqp 23:25:28 --aq-strength 10 --ref 1 --bframes 0 --gop-len 15 --lookahead 15 --qp-max 30 --aq --cabac --mv-precision q-pel --avsync cfr --colorprim auto --transfer auto --colormatrix auto --colorrange auto
My Computer
System One
-
- OS
- Windows 11
- Computer type
- Laptop
- Manufacturer/Model
- Lenovo Legion 7i
- CPU
- Intel i7-12800HX
- Memory
- 32 GB DDR5 4800 MHz dual-channel
- Graphics Card(s)
- NVIDIA® GeForce RTX™ 3080 Ti
- Sound Card
- Steinberg UR44
- Hard Drives
- 1 TB SSD (M.2 NVMe PCIe 4.0 x4
2 TB SSD Samsung 980 PRO NNMe
- Browser
- Firefox
- Antivirus
- Windows Defender + Malwarebytes