ffmeg thread_queue_size描述

聲明:轉帖時請註明出處

默認狀況下thread_queue_size取值爲8.

ffmpeg_opt.c open_input_file()html

#if HAVE_PTHREADS
    f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8;
#endif

 

ffmpeg官網對 thread_queue_size size 的說明

http://ffmpeg.org/ffmpeg.html大數據

-thread_queue_size size (input)this

This option sets the maximum number of queued packets when reading from the file or device. With low latency / high rate live streams, packets may be discarded if they are not read in a timely manner; raising this value can avoid it.spa

 

ffmpeg對 thread_queue_size size 的使用

static int init_input_threads(void)
{
    int i, ret;

    if (nb_input_files == 1)
        return 0;

    for (i = 0; i < nb_input_files; i++) {
        InputFile *f = input_files[i];

        if (f->ctx->pb ? !f->ctx->pb->seekable :
            strcmp(f->ctx->iformat->name, "lavfi"))
            f->non_blocking = 1;
        ret = av_thread_message_queue_alloc(&f->in_thread_queue,
                                            f->thread_queue_size, sizeof(AVPacket));
        if (ret < 0)
            return ret;

        if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) {
            av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
            av_thread_message_queue_free(&f->in_thread_queue);
            return AVERROR(ret);
        }
    }
    return 0;
}

 

總結:

對於輸入多個文件時,thread_queue_size的值會起做用。對於輸入一個文件時,thread_queue_size參數不起做用。code

當 thread_queue_size 值越大時,能夠保存的demux的數據越多,對於低延遲或者高碼率的視頻,可以保存較大數據,防止丟棄。orm

相關文章
相關標籤/搜索