[英]How do I enable FFMPEG logging and where can I find the FFMPEG log file?
I want to be able to log FFMPEG processes because I am trying to work out how long a minute of video takes to convert to help with capacity planning of my video encoding server.我希望能够记录 FFMPEG 进程,因为我正在尝试计算一分钟的视频转换需要多长时间,以帮助我进行视频编码服务器的容量规划。 How do I enable logging and where is the log file saved.
如何启用日志记录以及日志文件保存在哪里。 I have FFMPEG installed on a CentOS LAMP machine.
我在 CentOS LAMP 机器上安装了 FFMPEG。
FFmpeg does not write to a specific log file, but rather sends its output to standard error . FFmpeg 不会写入特定的日志文件,而是将其输出发送到标准错误。 To capture that, you need to either
要捕获它,您需要要么
Example for std error redirection:标准错误重定向示例:
ffmpeg -i myinput.avi {a-bunch-of-important-params} out.flv 2> /path/to/out.txt
Once the process is done, you can inspect out.txt
.该过程完成后,您可以检查
out.txt
。
It's a bit trickier to do the first option, but it is possible.做第一个选项有点棘手,但这是可能的。 (I've done it myself. So have others. Have a look around SO and the net for details.)
(我自己已经完成了。其他人也是如此。请查看 SO 和网络以了解详细信息。)
I found the below stuff in ffmpeg Docs.我在 ffmpeg Docs 中找到了以下内容。 Hope this helps!
希望这有帮助! :)
:)
Reference: http://ffmpeg.org/ffmpeg.html#toc-Generic-options参考: http : //ffmpeg.org/ffmpeg.html#toc-Generic-options
'-report' Dump full command line and console output to a file named program-YYYYMMDD-HHMMSS.log in the current directory.
'-report' 将完整的命令行和控制台输出转储到当前目录中名为 program-YYYYMMDD-HHMMSS.log 的文件中。 This file can be useful for bug reports.
此文件可用于错误报告。 It also implies -loglevel verbose.
它还意味着 -loglevel 详细。
Note: setting the environment variable FFREPORT to any value has the same effect.
注意:将环境变量 FFREPORT 设置为任何值都具有相同的效果。
I find the answer.我找到了答案。 1/First put in the presets, i have this example "Output format MPEG2 DVD HQ"
1/首先放入预设,我有这个例子“输出格式MPEG2 DVD HQ”
-vcodec mpeg2video -vstats_file MFRfile.txt -r 29.97 -s 352x480 -aspect 4:3 -b 4000k -mbd rd -trellis -mv0 -cmp 2 -subcmp 2 -acodec mp2 -ab 192k -ar 48000 -ac 2
If you want a report includes the commands -vstats_file MFRfile.txt into the presets like the example.如果您希望报告将命令 -vstats_file MFRfile.txt 包含到示例中的预设中。 this can make a report which it's ubicadet in the folder source of your file Source.
这可以在您的文件源的文件夹源中生成一个报告,它是 ubicadet。 you can put any name if you want , i solved my problem "i write many times in this forum" reading a complete .docx about mpeg properties.
如果你愿意,你可以输入任何名字,我解决了我的问题“我在这个论坛上写了很多次”阅读了关于 mpeg 属性的完整 .docx。 finally i can do my progress bar reading this txt file generated.
最后我可以做我的进度条读取这个生成的 txt 文件。
Regards.问候。
appears that if you add this to the command line:似乎如果您将其添加到命令行:
-loglevel debug
or或
-loglevel verbose
You get more verbose debugging output to the command line.您可以在命令行中获得更详细的调试输出。
ffmpeg logs to stderr, and can log to a file with a different log-level from stderr. ffmpeg 记录到 stderr,并且可以记录到与 stderr 具有不同日志级别的文件。 The
-report
command-line option doesn't give you control of the log file name or the log level, so setting the environment variable is preferable. -report
命令行选项无法让您控制日志文件名或日志级别,因此最好设置环境变量。
( -v
is a synonym for -loglevel
. Run ffmpeg -v help
to see the levels. Run ffmpeg -h full | less
to see EVERYTHING. Or consult the online docs , or their wiki pages like the h.264 encode guide ). (
-v
是-loglevel
的同义词。运行ffmpeg -v help
以查看级别。运行ffmpeg -h full | less
以查看所有内容。或查阅在线文档,或他们的 wiki 页面,如h.264 编码指南)。
#!/bin/bash
of=out.mkv
FFREPORT="level=32:file=$of.log" ffmpeg -v verbose -i src.mp4 -c:a copy -preset slower -c:v libx264 -crf 21 "$of"
That will trancode src.mp4
with x264, and set the log level for stderr to "verbose", and the log level for out.mkv.log
to "status".这将使用 x264 对
src.mp4
进行转src.mp4
,并将 stderr 的日志级别设置为“verbose”,并将out.mkv.log
的日志级别out.mkv.log
为“status”。
( AV_LOG_WARNING=24
, AV_LOG_INFO=32
, AV_LOG_VERBOSE=40
, etc.). (
AV_LOG_WARNING=24
, AV_LOG_INFO=32
, AV_LOG_VERBOSE=40
等)。 Support for this was added 2 years ago , so you need a non-ancient version of ffmpeg.对此的支持是2 年前添加的,因此您需要一个非古代版本的 ffmpeg。 (Always a good idea anyway, for security / bugfixes and speedups)
(无论如何,对于安全性/错误修复和加速而言,总是一个好主意)
A few codecs, like -c:v libx265
, write directly to stderr instead of using ffmpeg's logging infrastructure.一些编解码器,如
-c:v libx265
,直接写入 stderr 而不是使用 ffmpeg 的日志记录基础结构。 So their log messages don't end up in the report file.所以他们的日志消息不会出现在报告文件中。 I assume this is a bug / TODO-list item.
我认为这是一个错误/待办事项列表项。
To log stderr, while still seeing it in a terminal, you can use tee(1)
.要记录 stderr,同时仍然在终端中看到它,您可以使用
tee(1)
。
If you use a log level that includes status line updates (the default -v info
, or higher), they will be included in the log file, separated with ^M
(carriage return aka \\r
).如果您使用包含状态行更新的日志级别(默认
-v info
或更高),它们将包含在日志文件中,以^M
分隔(回车又名\\r
)。 There's no log level that includes encoder stats (like SSIM) but not status-line updates, so the best option is probably to filter that stream.没有包含编码器统计信息(如 SSIM)但不包含状态行更新的日志级别,因此最好的选择可能是过滤该流。
If don't want to filter (eg so the fps / bitrate at each status-update interval is there in the file), you can use less -r
to pass them through directly to your terminal so you can view the files cleanly.如果不想过滤(例如,每个状态更新间隔的 fps / 比特率都在文件中),您可以使用
less -r
将它们直接传递到您的终端,以便您可以干净地查看文件。 If you have .enc
logs from several encodes that you want to flip through, less -r ++G *.enc
works great.如果您有来自多个编码的
.enc
日志想要翻阅,则less -r ++G *.enc
效果很好。 (++G means start at the end of the file, for all files). (++G 表示从文件末尾开始,对于所有文件)。 With single-key key bindings like
.
使用单键键绑定,如
.
and ,
for next file and previous file, you can flip through some log files very nicely.并且
,
对于下一个文件和上一个文件,您可以很好地翻阅一些日志文件。 (the default bindings are :n
and :p
). (默认绑定是
:n
和:p
)。
If you do want to filter, sed 's/.*\\r//'
works perfectly for ffmpeg output.如果您确实想过滤,
sed 's/.*\\r//'
非常适合 ffmpeg 输出。 (In the general case, you need something like vt100.py
, but not for just carriage returns). (在一般情况下,您需要类似
vt100.py
东西,但不仅仅是回车)。 There are (at least) two ways to do this with tee + sed: tee
to /dev/tty and pipe tee's output into sed, or use a process substitution to tee into a pipe to sed.使用 tee + sed 有(至少)两种方法可以做到这一点:
tee
到 /dev/tty 并将 tee 的输出通过管道传输到 sed,或者使用进程替换将管道传输到管道到 sed。
# pass stdout and stderr through to the terminal,
## and log a filtered version to a file (with only the last status-line update).
of="$1-x265.mkv"
ffmpeg -v info -i "$1" -c:a copy -c:v libx265 ... "$of" |& # pipe stdout and stderr
tee /dev/tty | sed 's/.*\r//' >> "$of.enc"
## or with process substitution where tee's arg will be something like /dev/fd/123
ffmpeg -v info -i "$1" -c:a copy -c:v libx265 ... "$of" |&
tee >(sed 's/.*\r//' >> "$of.enc")
For testing a few different encode parameters, you can make a function like this one that I used recently to test some stuff.为了测试几个不同的编码参数,你可以制作一个类似我最近用来测试一些东西的函数。 I had it all on one line so I could easily up-arrow and edit it, but I'll un-obfuscate it here.
我把所有内容都放在一行上,这样我就可以轻松地向上箭头并对其进行编辑,但我会在这里取消混淆。 (That's why there are
;
s at the end of each line) (这就是为什么每行末尾都有
;
的原因)
ffenc-testclip(){
# v should be set by the caller, to a vertical resolution. We scale to WxH, where W is a multiple of 8 (-vf scale=-8:$v)
db=0; # convenient to use shell vars to encode settings that you want to include in the filename and the ffmpeg cmdline
of=25s@21.15.${v}p.x265$pre.mkv;
[[ -e "$of.enc" ]]&&echo "$of.enc exists"&&return; # early-out if the file exists
# encode 25 seconds starting at 21m15s (or the keyframe before that)
nice -14 ffmpeg -ss $((21*60+15)) -i src.mp4 -t 25 -map 0 -metadata title= -color_primaries bt709 -color_trc bt709 -colorspace bt709 -sws_flags lanczos+print_info -c:a copy -c:v libx265 -b:v 1500k -vf scale=-8:$v -preset $pre -ssim 1 -x265-params ssim=1:cu-stats=1:deblock=$db:aq-mode=1:lookahead-slices=0 "$of" |&
tee /dev/tty | sed 's/.*\r//' >> "$of.enc";
}
# and use it with nested loops like this.
for pre in fast slow; do for v in 360 480 648 792;do ffenc-testclip ;done;done
less -r ++G *.enc # -r is useful if you didn't use sed
Note that it tests for existence of the output video file to avoid spewing extra garbage into the log file if it already exists.请注意,它会测试输出视频文件是否存在,以避免在日志文件已经存在的情况下将额外的垃圾喷入日志文件中。 Even so, I used and append (
>>
) redirect.即便如此,我还是使用并附加 (
>>
) 重定向。
It would be "cleaner" to write a shell function that took args instead of looking at shell variables, but this was convenient and easy to write for my own use.编写一个接受 args 的 shell 函数而不是查看 shell 变量会“更干净”,但这对于我自己的使用来说很方便且容易编写。 That's also why I saved space by not properly quoting all my variable expansions.
这也是为什么我没有正确引用所有变量扩展来节省空间的原因。 (
$v
instead of "$v"
) (
$v
而不是"$v"
)
You must declare the reportfile as variable for console.您必须将报告文件声明为控制台变量。
Problem is all the Dokumentations you can find are not running so .. I was give 1 day of my live to find the right way ....问题是你能找到的所有文档都没有运行,所以……我有 1 天的时间来找到正确的方法……
Example: for batch/console示例:用于批处理/控制台
cmd.exe /K set FFREPORT=file='C:\\ffmpeg\\proto\\test.log':level=32 && C:\\ffmpeg\\bin\\ffmpeg.exe -loglevel warning -report -i inputfile f outputfile cmd.exe /K set FFREPORT=file='C:\\ffmpeg\\proto\\test.log':level=32 && C:\\ffmpeg\\bin\\ffmpeg.exe -loglevel warning -report -i inputfile f outputfile
Exemple Javascript:示例 JavaScript:
var reortlogfile = "cmd.exe /K set FFREPORT=file='C:\\ffmpeg\\proto\\" + filename + ".log':level=32 && C:\\ffmpeg\\bin\\ffmpeg.exe" .......; var reortlogfile = "cmd.exe /K set FFREPORT=file='C:\\ffmpeg\\proto\\" + 文件名 + ".log':level=32 && C:\\ffmpeg\\bin\\ffmpeg.exe" .... ...;
You can change the dir and filename how ever you want.您可以随意更改目录和文件名。
Frank from Berlin来自柏林的弗兰克
您只需添加选项 -loglevel debug 即可找到更多调试信息,完整命令将是
ffmpeg -i INPUT OUTPUT -loglevel debug -v verbose
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.