gpt4 book ai didi

android - Libav 和网络摄像头捕获

转载 作者:行者123 更新时间:2023-12-02 10:25:53 26 4
gpt4 key购买 nike

尝试使用 ffmpeg 打开网络摄像头(ffplay -f video4linux2/dev/video0 有效

    pFormatCtx = NULL;
av_register_all();
avcodec_register_all();
avformat_network_init();


const char device[] = "/dev/video0";
const char formatName[] = "video4linux";

if (!(pFormat = av_find_input_format(formatName))) {
printf("can't find input format %s\n", formatName);
return ;
}

if (avformat_open_input(&pFormatCtx, device, pFormat, NULL)!=0) {
printf("can't find open input file %s\n", device);
return ;
}

但 pFormat 始终为 0;

更新:以及如何从网络摄像头获取 mjpeg?

最佳答案

您应该在开始时调用 avdevice_register_all() 。

pFormatCtx = NULL;
av_register_all();
avdevice_register_all();
avcodec_register_all();
avformat_network_init();

const char device[] = "/dev/video0";
const char formatName[] = "video4linux";

if (!(pFormat = av_find_input_format(formatName))) {
printf("can't find input format %s\n", formatName);
return ;
}

if (avformat_open_input(&pFormatCtx, device, pFormat, NULL)!=0) {
printf("can't find open input file %s\n", device);
return ;
}

关于android - Libav 和网络摄像头捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24378837/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com