I'm trying to only have ffmpeg progress to be colored, but for some reason when I terminate or go full-screen this monstrosity occurs: Issue
@echo off
@echo off
title Stream Recorder
cls
:start
set message=Stream Recorder
echo %message%
echo(
echo [32m1. Chrome [0m
echo [34m2. Edge [0m
echo [33m3. Firefox [0m
echo [31m4. Opera [0m
echo [1;31m5. Vivaldi [0m
:choice
set choice=
set /p "choice=* Pick your browser (between 1-5): "
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto chrome
echo "%choice%" is not valid, try again.
ECHO.
goto choice
:chrome
:url
echo(
set /p "address=* M3U8 Url: "
For /F %%G In ('%__AppDir__%curl.exe -s -o NUL "%address%" -w "%%{http_code}\n"') Do Set "response=%%G"
echo %response%
IF %response% == 200 (
ECHO [32mURL check was successful.[m &goto :username
) ELSE (
ECHO [31mURL is not valid, try again.[m &goto :url
)
:username
set /p "filename=* Streamer Name: "
echo(
set message=* Recording:
echo [0m%message%[42;1m
ffmpeg -v warning -hide_banner -stats -user_agent "" -i "%address%" -c copy "%~dp0/%filename%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%_%time:~-11,2%-%time:~-8,2%-%time:~-5,2%.mp4"
pause
Also, would be helpful if my code needs some cleaning up.
That last echo is the problem:
The first Escape chunk turns off color and bold, while the second turns color and bold on.
To fix the problem, you need (at least)
before the
pause. But that may not be enough, becauseffmpegis printing to the terminal (presumably) without modifying colors. If it happens to clear the current line or to the end of the display, most terminals (supporting back color erase) will fill the cleared area with the current color.Perhaps you don't want
ffmpegto have that opportunity.