Here is a batch code where FOR reads each line from STDOUT and STDERR of the executed command and compares it with previous read line. If the newly read line is different to previously read line, this line is output to the file using redirection operator >>
.
@echo off
setlocal EnableExtensions EnableDelayedExpansion
del output.log 2>nul
set "Line="
for /F "delims=" %%I in ('ffmpeg.exe filename.mp4 -o filename.mkv 2^>^&1') do (
if not "!Line!" == "%%I" (
set "Line=%%I"
echo !Line!>>output.log
)
)
endlocal
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
del /?
echo /?
endlocal /?
for /?
if /?
set /?
setlocal /?
Read also the Microsoft article about Using Command Redirection Operators.
PS: I don't have ffmpeg
installed and therefore could not test above nor do I have the documentation for this tool installed. But take a look at ffmpeg output parse in batch script because I think all you really need is redirecting messages written to STDERR into the output file with:
ffmpeg.exe filename.mp4 -o filename.mkv 2>>output.log