[Ffmpeg-devel] Any pointers on how to connect to an MJPEG stream?
Thu Feb 22 18:36:03 CET 2007
Michel Bardiaux wrote:
> Robert Harle wrote:
>>>> I have a camera that outputs an MJPEG stream to my network
>>>> (connecting to http://camera_ip/mjpegstream). I want to be able to
>>>> obtain frames from the video using libavformat. I can do this from
>>>> a video file using av_open_input_file(), but I'm not sure how to
>>>> convert to a stream. At present I have:
>>>> av_open_input_file(&formatctx, filename, NULL, 0, NULL);
>>>> I see there is an av_open_input_stream() but I'm unsure as to the
>>>> parameters to pass to it, or even if this is intended to do what I
>>>> Can anyone offer a suggestion, or a resource to try?
>>> Try ffmpeg -i http://camera_ip/whatever -t 300 x.mpg , what happens?
>> It fails, unable recognise the format. I have to manually specify:
> My bad, which is why I wont take away points for not supplying the
> full output messages :-)
>> ffmpeg -f mjpeg -i http://camera_ip/whatever -t 300 x.mpg
>> and then it works fine. Similarly, ffplay -f mjpeg <URL> works
>> fine. Reading between the lines of your request, is it that
>> av_open_input_file() should take a URL and work, but the call fails
>> because it can't recognise a format from the URL?
> Exactly right. Now that you've got ffmpeg working, you can go in the
> source and see how it does it. I may be a hard slog, but at least
> you're sure you *will* find a solution.
> It is even possible that just giving the url an extension ".mjpg" will
> do the trick!
And, indeed, this works! Thank you so much! For the benefit of the
archives I now pass my program "http://<ip
address>/video?resolution=320x240,.mjpg" rather than "http://<ip
address>/video?resolution=320x240" and it is happy to use
More information about the ffmpeg-devel