RTST stream: Using VLC as the RTSP server
vlc2.1.2
vs2013+opencv3.0
C++
1, compile to remember to import VLC Vlc.dll, Vlccore.dll and Plugins folder, these can be downloaded from VLC official website after installation import
2, need to configure the OPENCV in VS2013
#include <opencv2\opencv.hpp> #include <iostream> #include <string> #include "vlc.h" #include "
StdAfx.h "#include" string.h "using namespace CV;
using namespace Std;
int video_width = 1024;
int video_height = 578;
static char * videobuf = 0;
String vlc_vertion= "";
void *lock (void *data, void**p_pixels) {*p_pixels = Videobuf;
return NULL;
} void display (void *data, void *id) {iplimage *img = Cvcreateimage (Cvsize (Video_width, Video_height), ipl_depth_8u, 4);
Img->imagedata = Videobuf;
Cvshowimage (Libvlc_get_version (), IMG);
Cvwaitkey (10);
Cvreleaseimage (&IMG);
} void Unlock (void *data, void *id, void *const *p_pixels) {(void) data;
ASSERT (id = = NULL);
} int main () {Cvnamedwindow ("image", cv_window_autosize);
libvlc_media_t* media = NULL;
libvlc_media_player_t* mediaPlayer = NULL;
Char const* vlc_args[] = {"-I", "dummy", "--ignore-config",};
Vlc_vertion=libvlc_get_version (); Videobuf = (char*) malloc ((Video_width * video_height) <<
2);
memset (videobuf, 0, (video_width * video_height) << 2);
libvlc_instance_t* instance = libvlc_new (sizeof (Vlc_args)/sizeof (Vlc_args[0]), Vlc_args);
Media = Libvlc_media_new_location (instance, "Rtsp://192.168.200.20:8554/test");
MediaPlayer = Libvlc_media_player_new_from_media (media);
Libvlc_media_release (media);
Libvlc_media_player_set_media (MediaPlayer, media);
Libvlc_video_set_callbacks (MediaPlayer, lock, unlock, display, NULL);
Libvlc_video_set_format (MediaPlayer, "RV32", Video_width, Video_height, video_width<<2);
Libvlc_media_player_play (MediaPlayer);
while (1) {} return 0; }
Resources:
VLC to do client-side solution for RTSP bitstream
http://blog.csdn.net/q339659207/article/details/38303831
Read MMS Stream for open CV
Http://stackoverflow.com/questions/9104842/read-mms-stream-for-open-cv