How to record logs of ffmpeg to a file?

fmpeg code outside the bash script works perfectly. For some reason when trying to write logs to a file using 2> - complains Unable to find a suitable output format for '2>'

I have the feeling that the system treats this as a command ffmpeg

#!/bin/bash
cmd="ffmpeg -re -i "xx.m3u8" -c:v copy-c:a aac-b:a 128k -ac 2 -strict -2 -f flv rtmp://localhost:1935/hls/home5 2> /var/log/nginx/home5.log"
$cmd
until $cmd ; do
 echo "restarting ffmpeg command..."
 sleep 2
done
April 19th 20 at 12:19
1 answer
April 19th 20 at 12:21
You have there the same type of quotation marks in the first place. This is not good.
Second, you redirect the output do not there. Bad call syntax.
Declare the function, it do what you need with referral and call her.
Here about defining and calling functions: https://habr.com/ru/company/ruvds/blog/327248/
function myfunc {
ffmpeg ... >> out.log
}
Detail as possible - elmo46 commented on April 19th 20 at 12:24

Find more questions by tags FFmpegbash