Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make FFmpeg C++ code not output error messages?

Tags:

c++

ffmpeg

I'm decoding video using FFmpeg's C++ library like this:

AVPacket* avPacket = av_packet_alloc();
if (!avPacket) std::cout << "av packet error" << std::endl;
int result = avcodec_send_packet(avCodecContext, avPacket);
    if (!result) {
        for ( ; !result ; ) {
            result = avcodec_receive_frame(avCodecContext, avFrame);
            if (!result) {
            ...

It works, but sometimes FFmpeg encounters problematic frames and emits the following:

[h264 @ 0x7fd3bc2c4b00] no frame!
[h264 @ 0x7fd3bc2c4b00] no frame!
[h264 @ 0x7fd3bc2c4b00] no frame!

Is it possible to turn off these messages? I don't see any obvious way to do it.

like image 381
Guerlando OCs Avatar asked Mar 04 '23 19:03

Guerlando OCs


2 Answers

In my code, I use av_log_set_callback() to redirect output messages to my own log file, so I can filter out unwanted messages before writing them to the log.

like image 150
Remy Lebeau Avatar answered Mar 14 '23 20:03

Remy Lebeau


I believe what you need is av_log_get_level and av_log_set_level.
Please check these out: https://www.ffmpeg.org/doxygen/trunk/group__lavu__log.html#gae8ada5cc5722548d8698650b05207904

like image 41
the kamilz Avatar answered Mar 14 '23 19:03

the kamilz