nt 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);
cvShowImage("image", 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_path(instance, "/home/zengwei/face/videorace/fashion1.mp4");
//media = libvlc_media_new_location(instance, "rtsp://192.168.5.11:554/user=admin&password=&channel=1&stream=0.sdp?");
media = libvlc_media_new_location(instance,"rtsp://192.168.5.140:8554/");
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;
}