working with VLC smem
working with VLC smem
我想做一些像这个帖子:使用libvlc smem从视频中获取帧并将其转换为opencv Mat. (c++)
我不太明白这部分的代码:
sprintf(smem_options
, "#transcode{vcodec=RV24}:smem{"
"video-prerender-callback=%lld,"
"video-postrender-callback=%lld,"
"video-data=%lld,"
"no-time-sync},"
, (long long int)(intptr_t)(void*)&cbVideoPrerender
, (long long int)(intptr_t)(void*)&cbVideoPostrender //This would normally be useful data, 100 is just test data
, (long long int)200 //Test data
);
上面写着video-data=%lld
。这是什么意思?它从哪里获取数据?
我正在使用文件对话框获取我的文件。我能把文件传给视频数据吗?
而不是使用VLC的smem
输出驱动程序,我建议直接与libvlc
交互,通过媒体播放器接口:
/* user_data is the pointer we passed to `video_set_callbacks()` */
void*lock_frame(void*user_data, void**planes) {
/* make '*plane* point to a memory you want the video-data rendered to */
*planes=user_data->img;
return user_data->pic;
}
void unlock_frame(void *user_data, void *picture, void *const *planes) {
/* image rendered into (*planes)==user_data->img; */
}
unsigned format_callback(void**user_data_ptr; char*chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines) {
mydata_t*user_data=(mydata_t*)(*user_data_ptr);
/* set the output format to RGBA */
memcpy(chroma, "RV32", 4); /* 'RV32' is 'RGBA'
/* leave dimensions intact, but store them
* now's the time to resize user_data->img to hold that much memory
*/
user_data->width =*width;
user_data->height=*height;
*pitches=(*width)*4; /* 4 is the pixel size for RGBA */
*lines=*height;
return 1;
}
vlc_inst=libvlc_new (0, 0);
libvlc_media_t*media = libvlc_media_new_location (vlc_inst, location);
libvlc_media_player_t*mplayer=libvlc_media_player_new_from_media(media);
libvlc_video_set_callbacks(mplayer,
lock_frame, unlock_frame,
0, user_data);
libvlc_video_set_format_callbacks(data->m_mediaplayer, format_callback,0);
libvlc_media_player_play(mplayer);
/* the media-player will call
* - format_callback() with a format suggestion which you can adjust to your needs
* - lock_frame()/unlock_frame() whenever a new frame has arrived.
* once you are done, call: */
libvlc_media_player_stop(mplayer);
libvlc_release(vlc_inst);
相关文章:
- 正确地编写一个类,并将pthread与vlc库和c++一起使用
- 设置 VLC drawable-hwnd 仍会创建一个新窗口
- 如何使用VLC-QT从视频中获取框架
- Windows窗体应用程序无法播放视频[VLC ActiveX插件和IE Web插件v2]
- 如何使用来自vlc媒体播放器的QNetworkAccessManager源代码
- Visual如何使用OPENCV(C 代码)访问IP摄像机?有没有一种方法可以使用OpenCV VLC访问?(Win
- 流记录程序VLC
- 支持 opencv 的 VLC 编译中出现错误
- VLC如何在桌面上播放视频
- VLC 命令行音频/视频流
- 从 IP 摄像机流式传输在 VLC 上非常抖动.
- 如何使用C ++在VLC中播放MP3文件
- 为安卓编译 VLC 时出现问题 - libvlcjni.so
- 如何编写可以与操作系统交互的VLC插件
- VLC libx264流复用为FLV
- 在VLC对象上绘制项目
- working with VLC smem
- 接收WebRTC在VLC/FFMPEG或其他应用程序
- 从c++代码触发VLC播放器
- 如何使用vlc或其他东西播放mp4文件的随机部分