我怎么能拒绝了libavformat错误消息关闭 [英] How can I turn libavformat error messages off
问题描述
在默认情况下,libavformat流将错误信息写入标准错误
,像
By default, libavformat writes error messages to stderr
, Like:
从比特率的估计持续时间,这可能是不准确的
我怎样才能把它关掉?或更好,但它管我自己的整齐的日志记录功能?
How can I turn it off? or better yet, pipe it to my own neat logging function?
编辑:重定向错误输出到别的地方是不能接受的,因为我想在其他日志记录,我只是想libavformat去不写它
Redirecting stderr to somewhere else is not acceptable since I need it for other logging purposes, I just want libavformat to not write to it.
推荐答案
通过code来看,它似乎可以通过编写自己的回调函数为 av_log $更改行为C $ C>功能。
Looking through the code, it appears you can change the behavior by writing your own callback function for the av_log
function.
从这个功能的<一个描述href=\"http://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=libavutil/log.h;hb=HEAD\">libavutil/log.h:
发送指定的消息的日志,如果水位小于或等于
到当前av_log_level。默认情况下,所有日志消息被发送到
标准错误。 这个行为可以通过设置不同的回调av_vlog改变
功能
Send the specified message to the log if the level is less than or equal to the current av_log_level. By default, all logging messages are sent to stderr. This behavior can be altered by setting a different av_vlog callback function.
该API提供了一个功能,让你定义自己的回调:
The API provides a function that will allow you to define your own callback:
void av_log_set_callback(void (*)(void*, int, const char*, va_list));
在你的情况,你可以写完全丢弃的消息(或者其重定向到一个专门的日志等)没有玷污你的标准错误
流一个简单的回调函数。
In your case, you could write a simple callback function that discards the messages altogether (or redirects them to a dedicated log, etc.) without tainting your stderr
stream.
这篇关于我怎么能拒绝了libavformat错误消息关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!