0

In windows, How does one change STDERR before writing it to an out file?

The goal is to create one log file containing all the ffmpeg integrity errors.

ffmpeg-recursive-error.bat

@echo off

set "_var1_DoHeading=ZZZ"

FOR /R "S:#MiscDownloads\test" %%G IN (*.mp4) DO ( echo Processing... %%G set "_var1_DoHeading=YES" echo [a - The value of _var1_DoHeading is %_var1_DoHeading% ] for /f "usebackq delims==" %%H in (ffmpeg.exe -xerror -v error -i "%%G" -f null - 2^>^&1) do ( if %_var1_DoHeading%==YES ( echo ==================== echo %%G ) set "_var1_DoHeading=NO" echo [b - The value of _var1_DoHeading is %_var1_DoHeading% ] echo %%H )
) echo Done

Error

PS C:\duplicate-file-finder> .\ffmpeg-check-for-errors.bat

Processing... S:#MiscDownloads\test\test_video.mp4

[a - The value of _var1_DoHeading is ZZZ ]

[b - The value of _var1_DoHeading is ZZZ ]

[aac @ 000001b1848bed40] channel element 0.0 is not allocated

[b - The value of _var1_DoHeading is ZZZ ]

[h264 @ 000001b184936b80] error while decoding MB 60 21, bytestream -7

Done

References:

1 Answers1

0

There are no environment variables for STDIN and STDERR. You need to explicitly pipe them into some other command.

I would suggest this syntax:

for /f "delims=" %%a in ('ffmpeg ... 2^>^&1') do set "myvar=%%a"

The output of ffmpeg will become the value of myvar and can be used by %myvar%.

The ^ is the batch escape character. If you will need quotes for parameters in the ffmpeg command, use the usebackq option for replacing them with back-quotes.

For more information see the FOR /F command.

harrymc
  • 498,455