Tuesday, April 3, 2018

command line - How To Stop Batch File From Opening New Windows?

I'm making a batch file that uses ffmpeg and ffprobe to encode a video. But every time I drag and drop my video onto the batch file, it opens a new command window.


How can I keep just one command window open, and have the batch file run in the same window every time, instead of opening a new one?


I run the batch file by drag and dropping my video files onto it.


Here is my batch code:


for /f %%i in ('D:\SOFTWARE\ffmpeg\bin\ffprobe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%~1"') do set height=%%i
IF %height% GEQ 2160 (
echo "its above 2160!"
set bitrate=35000
) ELSE IF %height% GEQ 1440 (
echo "its above 1440!"
set bitrate=16000
) ELSE IF %height% GEQ 1080 (
echo "its above 1080!"
set bitrate=8000
) ELSE IF %height% GEQ 720 (
echo "its above 720!"
set bitrate=5000
) ELSE IF %height% GEQ 480 (
echo "its above 480!"
set bitrate=2500
) ELSE IF %height% GEQ 360 (
echo "its above 360!"
set bitrate=1000
) ELSE (
echo "its below 360!"
set bitrate=1000
)
D:\SOFTWARE\ffmpeg\bin\ffmpeg -i "%~1" -c:v libx264 -preset slow -b:v %bitrate%k -c:a aac -b:a 192k -ac 2 "%~p1%~n1-out-h264.mp4"
cmd /k

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...