ffmeg thread_queue_size描述

默认thread_queue_size为8,用于限制输入文件时待处理的包数量。ffmpeg官网建议提高该值避免低延迟/高码率直播丢包。thread_queue_size只在处理多个输入文件时生效,大值能存储更多demux数据,防止丢帧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

声明:转帖时请注明出处

默认情况下thread_queue_size取值为8.

ffmpeg_opt.c open_input_file()

#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 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.

 

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参数不起作用。

当 thread_queue_size 值越大时,可以保存的demux的数据越多,对于低延迟或者高码率的视频,能够保存较大数据,防止丢弃。

转载于:https://my.oschina.net/u/2326611/blog/682799

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值