[Libav-user] How to clear real-time buffer?

DDD ZZZ mymail67 at mail.ru
Thu Nov 29 15:16:37 EET 2018


Hi everybody!
Here's the part of c++ code that I'm using to access my webcam.

**********************************************************************
**********************************************************************
int Camera::Init(char* file_name,
                char* device_name,
                char* format,
                char* resolution,
                char* frame_rate,
                char* pixel_format)
{
    av_log(NULL, AV_LOG_INFO, "---INIT STARTED---\n");
    avdevice_register_all();
    av_register_all();

    AVDictionary* properties_collection = NULL;
    av_dict_set(&properties_collection, "f", format, NULL);
    av_dict_set(&properties_collection, "video_size", resolution, NULL);
    av_dict_set(&properties_collection, "framerate", frame_rate, NULL);
    av_dict_set(&properties_collection, "pix_fmt", pixel_format, NULL);
    AVInputFormat *input_format = av_find_input_format("dshow");
    char command_line[256];
    sprintf(command_line, "video=%s", device_name);
    AVFormatContext *input_context = avformat_alloc_context();
    //input_context->flags |= AVFMT_FLAG_NOBUFFER;      //DOESN'T HELP
    //input_context->max_picture_buffer = 0;            //ERR

    int err_code = 0;
    err_code = avformat_open_input(&input_context,
                                    command_line,
                                    input_format,
                                    &properties_collection);

////////////////////////////////////// 
//////////PROBLEM SECTION/////////////
////////////////////////////////////// 
    int i = 0;
    while (i++ < 30)
    {
        Sleep(1000);
        //avformat_flush(input_context); //DOESN'T HELP
        //av_free(input_context); //ERR
    }
////////////////////////////////////// 
    system("pause");
    return 0;
} **********************************************************************
**********************************************************************

Right after " avformat_open_input() " it starts reading frames to some internal buffer without me even calling " av_read_frame() ". After about 10 seconds it start's giving me error messages:

[dshow @ 0014ed40] real-time buffer [VirtualBox Webcam - FULL HD 1080P Webcam] [video input] 
too full or near too full (62% of size: 3041280 [rtbufsize parameter])! 
frame dropped!
...
...
...
[dshow @ 0014ed40] real-time buffer [VirtualBox Webcam - FULL HD 1080P Webcam] [video input] 
too full or near too full (100% of size: 3041280 [rtbufsize parameter])! 
frame dropped!


Q: How to clear this buffer or avoid using it?
Thanks in advance.


P.S.Please pardon my english.
P.P.S.Have a good day.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20181129/3d7ce863/attachment.html>


More information about the Libav-user mailing list