2>&1并同时记录日志文件

I'm using this code to run ffmpeg and return when it succeeded or failed using 2> & 1 and $var. The problem is that I would also like to generate a log.txt with the current ffmpeg process. I know it does using 2> log.txt but how do I use both options at the same time?

<?php
$ffmpeg = '"D:\FFMPEG\bin\ffmpeg.exe"' . " -loglevel verbose -n -i https://URLVIDEO -map p:0 -acodec copy -bsf:a aac_adtstoasc -vcodec copy video.mp4 2>&1";

    exec($ffmpeg, $output, $var);

    if($var){
       echo 'error';
    }else{

      echo 'success';

    }
?>

Use 1> log.txt 2>&1.

stdout is redirected to the log file and stderr is appended to stdout.

If I understood correctly, you want both streams to be logged. If so, another option is to use &> e.g. cmd &> log.txt.