【问题标题】:Libav and web cam capturingLibav 和网络摄像头捕获
【发布时间】:2014-06-24 05:20:52
【问题描述】:

尝试使用 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?

【问题讨论】:

    标签: android c++ ffmpeg webcam


    【解决方案1】:

    您应该在开始时调用 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 ;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      • 2013-02-09
      • 2015-04-12
      • 1970-01-01
      • 2011-11-24
      相关资源
      最近更新 更多