<div dir="ltr">Hi<div><br></div><div>I am investigating why opencv on raspberry pi isn't able to connect to the camera using video4linux and the "/dev/video0" device handle. I've managed to trace the error to opencv calling avformat_open_input. When this function is called it returns an <span style="color:rgb(0,0,0);white-space:pre-wrap">AVERROR_INVALIDDATA (</span><span style="color:rgb(0,0,0);white-space:pre-wrap">0xbebbb1b7</span><span style="color:rgb(0,0,0);white-space:pre-wrap">) error code. I have been able to reproduce this using:</span></div>

<div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><font color="#000000"><span style="white-space:pre-wrap">#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavutil/file.h>
int main(int argc, char *argv[])
{
    AVFormatContext *fmt_ctx = NULL;
    int ret = 0;
    av_log_set_level(AV_LOG_DEBUG);
    av_register_all();
    ret = avformat_open_input(&fmt_ctx, "/dev/video0", NULL, NULL);
    if (ret < 0) {
        fprintf(stderr, "Could not open input: %08x\n", ret);
    }
    return 0;
}</span></font><br></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">I note in the above code sample I am using a null AVFormatContext. This seems to be what opencv does too. Should this code return </span><span style="color:rgb(0,0,0);white-space:pre-wrap">an </span><span style="color:rgb(0,0,0);white-space:pre-wrap">AVERROR_INVALIDDATA error? The error appears to occur during </span><font color="#000000"><span style="white-space:pre-wrap">av_opt_set_defaults2 function. Another possibility is </span></font><span style="color:rgb(0,0,0);white-space:pre-wrap">that raspberry pi's video4linux driver needs to be pre-configured initially although I am not sure.</span></div>

<div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">Any help or pointers would be greatly appreciated :)</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">Thanks</span></div>

<div><span style="color:rgb(0,0,0);white-space:pre-wrap">Blair</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div>

</div>