[Libav-user] How to connect to an IP camera in libav

Alexander Wischnewski aw.wisch at googlemail.com
Mon Dec 3 15:55:16 CET 2012


Hello Brian,

not long ago i ran into a similar problem so i have a clue what it could
be. In some cases, when it comes to receiving a live stream, you have to
tell ffmpeg which format the input should have. Attached you find some code
how to do that, i am using it for several mjpeg cameras.
AVInputFormat* avInformat = NULL;

avInformat = av_find_input_format("mjpeg");

if(avformat_open_input(&pFormatCtx, path, avInformat, NULL)!=0)
{ ...

Best regards,
Alex
Am 29.11.2012 21:07 schrieb "Brian Martin" <brian at caelumspace.com>:

> Hello,****
>
> ** **
>
> I’m trying to connect to a Foscam MJpeg IP camera (http) using libav on
> Windows and am getting an error code of -5 after ****
>
> ** **
>
> AVFormatContext *pFormatCtx=NULL;****
>
>                 int             i, videoStream;****
>
>                 AVCodecContext  *pCodecCtx;****
>
>                 AVCodec         *pCodec;****
>
>                 AVFrame         *pFrame; ****
>
>                 AVFrame         *pFrameRGB;****
>
>                 AVPacket        packet;****
>
>                 int             frameFinished;****
>
>                 int             numBytes;****
>
>                 uint8_t         *buffer;****
>
>                 struct SwsContext *img_convert_ctx;****
>
>                 int frameCount=0;****
>
> ** **
>
>                 if(!videoStreamAddress) {****
>
>                                 printf("Please provide a movie file\n");**
> **
>
>                                 return -1;****
>
>                 }****
>
>                 // Register all formats and codecs****
>
>                 av_register_all();****
>
>                 avformat_network_init();****
>
> ** **
>
>                 //Open video file****
>
>                 if(avformat_open_input(&pFormatCtx, videoStreamAddress,
> NULL, NULL)!=0)****
>
>                 {****
>
>                                 printf("Couldn't open file %s\n",
> videoStreamAddress);****
>
>                                 return -1; // Couldn't open file****
>
>                 }****
>
> ** **
>
> I tried to get the string value of this error but am getting a write
> protected memory error using the built-in av_strerror command.****
>
> Any ideas would be appreciated. Thanks!****
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121203/a80f0493/attachment.html>


More information about the Libav-user mailing list