Solved Anyone with scripting skills, can you plz help me add options from one script to another!?


rezpower

Well-known member
Member
VIP
Local time
1:02 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:

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
Batch:
@echo off
set "minfo=D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe"

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" (
    call :get_size "%%i"
    if /I not "%%~xi" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    )
)
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" (
    call :get_size "%~1"
    if /I not "%~x1" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    )
)

: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

)

exit

:get_size
for /f "tokens=1,2" %%a in ('%minfo% "--Inform=Video;%%Width%% %%Height%%" %1') do (
  set width=%%a
  set height=%%b
)
set /a hwidth=%width%/2
set /a ewidth=%width%/16
set /a eheight=%height%/8
exit /b
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
@hdmi
Thanks a lot for your help :)
I tried the script and it gives me these errors:
'D:\Software\Shared' is not recognized as an internal or external command,
operable program or batch file.
Missing operand.
Missing operand.
Missing operand.
The system cannot find the path specified.
 

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
try

set minfo="D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe"

instead of

set "minfo=D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe"
 

My Computers

System One System Two

  • OS
    Win7,Win11
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7,win11
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
try

set minfo="D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe"

instead of

set "minfo=D:\Software\Shared Programs Elitebook\MediaInfo\CLI Version\MediaInfo.exe

Done, but still the same error!

'D:\Software\Shared' is not recognized as an internal or external command,
operable program or batch file.
Missing operand.
Missing operand.
Missing operand.
The system cannot find the path specified.
====================== Processing is FINISHED =======================
----------------------------
Batch processing start time: 0:04:12.05, Wed 07/24/2024
Batch processing end time: 0:04:12.26, Wed 07/24/2024
----------------------------
Your computer is about to shutdown in 10 min do you want to abort (y/n):
 

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
I tried to put MediaInfo.exe in C:\CLI and changed the script accordingly.

This fixed the problem. but I am having cropping error .
Error: Invalid value "0,0,,0" for "--crop"
It seems that the script is not setting crop values at all!
 
Last edited:

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
Near the bottom of the script, enclose %minfo% in doublequotes. The line:
for /f "tokens=1,2" %%a in ('%minfo% "--Inform=Video;%%Width%% %%Height%%" %1') do (
...should be:
for /f "tokens=1,2" %%a in ('"%minfo%" "--Inform=Video;%%Width%% %%Height%%" %1') do (

Sorry for my mistake.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Done. Once I replaced that line I now get this error:
'C:\CLI\MediaInfo.exe" "--Inform' is not recognized as an internal or external command,
operable program or batch file.
Missing operand.
Missing operand.
Missing operand.
Error: Invalid value "0,0,,0" for "--crop"


Before I was only getting:
Error: Invalid value "0,0,,0" for "--crop"
 

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
Batch:
@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" (
    call :get_size "%%i"
    if /I not "%%~xi" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    )
)
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" (
    call :get_size "%~1"
    if /I not "%~x1" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    )
)

: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

)

exit

:get_size
for /f "tokens=1,2" %%a in ('C:\CLI\MediaInfo.exe "--Inform=Video;%%Width%% %%Height%%" %1') do (
  set width=%%a
  set height=%%b
)
set /a hwidth=%width%/2
set /a ewidth=%width%/16
set /a eheight=%height%/8
exit /b
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
no more error except:
Error: Invalid value "0,0,,0" for "--crop"
the value for crop is not set and remains ,, empty!
I am really sorry that you got yourself into this trouble hdmi ! You should have done like 100% other members and not get urself into trouble :)

I don't know if you already have NVEnc and mediainfo on your PC or not. But if ever you want to give this a try here is a link to NVEncC64 and here is a link for Mediainfo Cli. Both are compressed files and only need to be copied to a folder (no need to install). For the script to run, it should be copied into NVEncC64 folder. All you need to do is to drag and drop a .mp4 video file on it and see if it works.
 

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
I only got MediaInfo CLI, but I think I finally figured it out.

Batch:
@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
setlocal EnableExtensions EnableDelayedExpansion
for %%i in (*.mp4 *.avi *.mov *.wmv *.ts *.m2ts *.mkv) do if not exist "%ProxyDir%\%%~ni_proxy.mp4" (
    call :get_size "%%i"
    if /I not "%%~xi" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%%i" -o "%ProxyDir%\%%~ni_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
    )
)
endlocal
if defined Restorefolder popd
goto OutputInfo

:SingleFile
if exist "%~1" goto ProcessFile
echo ERROR: Could not find "%~1"!
echo/
pause
exit /B 1

:ProcessFile
setlocal EnableExtensions EnableDelayedExpansion
if not exist "%ProxyDir%\%~n1_proxy.mp4" (
    call :get_size "%~1"
    if /I not "%~x1" == ".avi" (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    ) else (
        "%~dp0nvencc\NVEncC64.exe" -i "%~1" -o "%ProxyDir%\%~n1_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
    )
)
endlocal

: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
)

exit

:get_size
for /f %%a in ('C:\CLI\MediaInfo.exe "--Inform=Video;%%Width%%" %1') do set width=%%a
set /a hwidth=!width!/2
exit /b
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
The system cannot find the path specified.
it doesn't say which path!
:(
 

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
MediaInfo CLI is still in C:\CLI, correct? Could you please make a test version of the script by substituting each of all 4 occurrences of
"%~dp0nvencc\NVEncC64.exe" with echo "%~dp0nvencc\NVEncC64.exe"? Doing this should cause the script to, each time when they are encountered, merely write these commands to the command window as opposed to excecute them. Hopefully it will help to show some detail of what might be going on.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Yes CLI folder is still in C:\

I did the changes as you indicated and here is the result! The original video Width is 5400 pixels and the crop is done correctly here!!
But this path is wrong: "D:\Software\Shared Programs Elitebook\\Stream\Halflife_alyx-3d_2700_LR_180.mp4"

The correct path is: "D:\Stream\Halflife_alyx-3d_2700_LR_180.mp4"


"D:\Software\Shared Programs Elitebook\\Stream\Halflife_alyx-3d_2700_LR_180.mp4" -o "C:\Users\Elitebook\Desktop\Proxy\Halflife_alyx-3d_2700_LR_180_proxy.mp4" --crop 0,0,2700,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
====================== Processing is FINISHED =======================
----------------------------
Batch processing start time: 15:55:16.02, Fri 07/26/2024
Batch processing end time: 15:55:16.28, Fri 07/26/2024
 

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
See what happens if you put the file NVEncC64.exe in the folder C:\CLI and substitute "%~dp0nvencc\NVEncC64.exe" with "C:\CLI\NVEncC64.exe" in all 4 places.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
YES! its now working :clap:

I don't know how to thank you for the time you put helping me with this! I am really grateful. :loveit:
There was a problem with a folder name for NVEncC64.exe
it was: "D:\Software\Shared Programs Elitebook\!proxy generator\nvencc\NVEncC64.exe"
Removing the ! from the "Proxy generator" folder fixed it.

Also there was a problem with mediainfo.exe. Folders with space in the name would not work!
I just removed the spaces in the folder name and was able to put mediainfo.exe back to D:\Software folder.

here is the final working script for reference:

Code:
@echo off
for /f "tokens=4 delims= " %%f in ('powercfg /getactivescheme') do (
  set ACTIVE_SCHEME=%%f
)

powercfg /setactive 62a1340d-2a81-4ed5-9915-799c7a37315c
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
setlocal EnableExtensions EnableDelayedExpansion
for %%i in (*.mp4 *.avi *.mov *.wmv *.ts *.m2ts *.mkv) do if not exist "%ProxyDir%\%%~ni_proxy.mp4" (
    call :get_size "%%i"
    if /I not "%%~xi" == ".avi" (
        "D:\Software\Shared Programs Elitebook\01proxy generator\nvencc\NVEncC64.exe"  -i "%%i" -o "%ProxyDir%\%%~ni_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
    ) else (
        "D:\Software\Shared Programs Elitebook\01proxy generator\nvencc\NVEncC64.exe"  -i "%%i" -o "%ProxyDir%\%%~ni_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
    )
)
endlocal
if defined Restorefolder popd
goto OutputInfo

:SingleFile
if exist "%~1" goto ProcessFile
echo ERROR: Could not find "%~1"!
echo/
pause
exit /B 1

:ProcessFile
setlocal EnableExtensions EnableDelayedExpansion
if not exist "%ProxyDir%\%~n1_proxy.mp4" (
    call :get_size "%~1"
    if /I not "%~x1" == ".avi" (
        "D:\Software\Shared Programs Elitebook\01proxy generator\nvencc\NVEncC64.exe"  -i "%~1" -o "%ProxyDir%\%~n1_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
    ) else (
        "D:\Software\Shared Programs Elitebook\01proxy generator\nvencc\NVEncC64.exe"  -i "%~1" -o "%ProxyDir%\%~n1_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
    )
)
endlocal

: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
)

exit

:get_size
for /f %%a in ('D:\Software\Desktop\MediainfoCLi\MediaInfo.exe "--Inform=Video;%%Width%%" %1') do set width=%%a
set /a hwidth=!width!/2
exit /b
 

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
YES! its now working :clap:

I don't know how to thank you for the time you put helping me with this! I am really grateful. :loveit:
There was a problem with a folder name for NVEncC64.exe
it was: "D:\Software\Shared Programs Elitebook\!proxy generator\nvencc\NVEncC64.exe"
Removing the ! from the "Proxy generator" folder fixed it.
This is because exclamation marks get treated like the start of a variable name when delayed expansion is enabled (with Setlocal EnableDelayedExpansion). The same also happens if exclamation marks are found in the filepath of a videofile when delayed expansion is enabled so, you should make sure that none of your videofiles have any exclamation marks in their filename before you try to use this batch script on them.
Also there was a problem with mediainfo.exe. Folders with space in the name would not work!
I just removed the spaces in the folder name and was able to put mediainfo.exe back to D:\Software folder.
Yeah, I noticed the same. Spaces in the filename of videofiles should still work, though. (But you might want to verify on that. :D)
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF

Latest Support Threads

Back
Top Bottom