How to get MJPG stream video from android IPWebcam using opencv
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 ...