FFMPEG记录(一)——loglevel控制日志打印级别
Date: April 29, 2022
Property: jinxi li
loglevel控制日志打印级别
-
日志级别含义:
shell输出重定向到文件
question:
运行如下命令,output.txt无输出,log信息仍然显示在terminal上,没在txt中
ffmpeg -i test.flv -vcodec copy -acodec copy output.mkv > output.txt
reason:
-
上图ffmpeg loglevel中有提到:
By default the program logs to stderr.
即:调用ffmpeg相关命令,打印信息都被终端认为是错误输出但是一般情况下这种信息也会输出到屏幕上,所以我们可以在屏幕上看到它。但是,当我们想重定向到文件中,却被系统认为是错误输出而忽略。
-
在shell中,0表示键盘输出,1表示屏幕输出,2表示错误输出。cmd > file,只是把屏幕输出重定向到文件中。
solution:
Redirect the stderr to the same place we are redirecting the stdout
2>&1
: &标明其后面跟的是一个文件描述符,而不是一个文件名。
&1
:to reference the value of the file descriptor 1 (stdout).
ffmpeg -i test.flv -vcodec copy -acodec copy -y output.mkv > output.txt 2>&1