On date Sunday 2009-07-05 15:08:37 +0200, Maróy Ákos encoded:
> Hi,
>
> I'm trying to grab images from a webcam, and I'm trying to use the  
> following code:
>
> AVCodecContext  *pCodecCtx;
> AVInputFormat   *pFormat;
> const char      device[]     = "/dev/video0";
> const char      formatName[] = "video4linux";
>
>
> av_register_all();
>
> if (!(pFormat = av_find_input_format(formatName))) {
>     printf("can't find input format %s\n", formatName);
>     return -1;
> }
>
> if (av_open_input_file(&pFormatCtx, device, pFormat, 0, NULL)!=0) {
>     printf("can't find open input file %s\n", device);
>     return -1;
> }
>
>
>
> but I'm finding that I always get a null as a return value from  
> av_find_input_format(). I tried all sort os values for formatName,  
> ranging from mp2, mp4, dv1394, h264, video4linux and video4linux2. all  
> these values are listed when I issue:
>
> ffmpeg -formats

You need to register all the *devices* using avdevice_register_all(),
then you should be able to get the video4linux input format (assuming
it has been compiled into your libavdevice).

Follows a little app to show you all the register input
formats/devices.

#include <stdio.h>
#include <libavformat/avformat.h>

int main(int argc, char **argv)
{
    AVInputFormat *p = NULL;
    av_register_all();
    avdevice_register_all();

    while (p = av_iformat_next(p))
        printf("%s: %s:\n", p->name, p->long_name);

    return 0;
}

Regards.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to