Ask Your Question
0

How to get MJPG stream video from android IPWebcam using opencv

asked 2013-03-10 22:30:57 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

I have an Android phone.I want to stream video from it by IPwebcam.It's an app for Android to stream video. I have just downloaded Opencv-2.3.1 and edit it. In the file OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp In the function bool CvCapture_FFMPEG::open( const char* _filename )

+replace:

int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);

+by

AVInputFormat* iformat = av_find_input_format("mjpeg");
int err = av_open_input_file(&ic, _filename, iformat, 0, NULL);
ic->iformat = iformat;

+and comment:

err = av_seek_frame(ic, video_stream, 10, 0);
if (err < 0)
{
    filename=(char*)malloc(strlen(_filename)+1);
    strcpy(filename, _filename);
    // reopen videofile to 'seek' back to first frame
    reopen();
}
else
{
    // seek seems to work, so we don't need the filename,
    // but we still need to seek back to filestart
    filename=NULL;
    int64_t ts    = video_st->first_dts;
    int     flags = AVSEEK_FLAG_FRAME | AVSEEK_FLAG_BACKWARD;
    av_seek_frame(ic, video_stream, ts, flags);
}

But when I make it with follow some errors:

[ 30%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o
In file included from /root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::reopen()’:
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:486:5: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:486:52: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:494:5: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3612) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:494:50: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3612) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:497:5: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:497:28: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::open(const char*)’:
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:525:15: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:525:66: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:543:9: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3612) [-Wdeprecated-declarations]
/root/Downloads/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:543:54: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-03-11 11:42:49 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Current version of OpenCV is 2.4.4. Since 2.3.1 a lot of FFMPEG related fixes have been done, e.g. changes for support of new FFMPEG versions. I recommend you to update OpenCV and try again.

edit flag offensive delete link more

Comments

My stream ( URL:[IP]:8080/videofeed ) is working with VLC, Firefox,IE,Chrome but use Opencv is not working :( .Now,I'm building Opencv-2.4.4.I hope it's working :|

Diep gravatar imageDiep ( 2013-03-11 21:36:28 -0500 )edit

Thank Alex.I have builded OpenCV-2.4.4 successfully on Ubuntu 11.10.And It's working with my stream URL://IP:8080/videofeed.It's great ^^.Thank you so much !

Diep gravatar imageDiep ( 2013-03-11 23:37:52 -0500 )edit

Hi Alexander ! Thank you for help! I build OpenCV-2.4.4 on Ubuntu 11.10 and programming on Qt.I have got my stream from IP webcam Now I build OpenCV-2.4.5 on Windows 7 and programming on VS2010 but I don't get my stream video from IP webcam. Can you help me or give me some suggests?

Diep gravatar imageDiep ( 2013-04-11 23:33:38 -0500 )edit

Check that you use FFMPEG as back-end on Windows and it is new. Try to update it.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-04-12 09:16:09 -0500 )edit

Hi Alexander ! I have downloaded FFMPEG on http://ffmpeg.zeranoe.com/builds/ (Previous FFmpeg 32-bit Shared Versions). Open it I see 4 folders with some .DLL . Now I want to use some .DLL in VS2010. I have just added PATH C:/Direct/to/Folder/FFMEGP/bin and built my project but have the same error ( Could not find codec parameters ( ../../modules/highgui/src/cap_ffmpeg_impl.hpp:540) ) Do I need to rebuild Opencv-2.4.5 by Cmake-GUI and VS2010 and add FFMPEG ? Can you give me some suggests? Thank you so much !

Diep gravatar imageDiep ( 2013-04-15 04:01:36 -0500 )edit

code wont paste srry

MrLunk gravatar imageMrLunk ( 2018-10-29 15:39:25 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-03-10 22:30:57 -0500

Seen: 1,551 times

Last updated: Mar 11 '13