我正在尝试使用libvlc + smem捕获视频流帧。一切都很好,除非当VLC调用我的postrend函数时,我得到的 height arg总是比实际值大16px。这是我设置VLC的方法
// createing instance
cv::namedWindow("wnd", cv::WINDOW_FULLSCREEN);
const char *args[] {
"--ignore-config",
"--quiet",
};
auto instance = libvlc_new(sizeof(args) / sizeof(args[0]), args);
auto media = libvlc_media_new_location(instance, "http://streams.videolan.org/samples/MPEG-4/video2.mp4");
// setting up media
const char *vcodec = "RV24";
char options[1024] = {0};
sprintf(
options,
":sout=#transcode{"
"vcodec=%s,"
"}:smem{"
"%s,"
"video-prerender-callback=%lld,"
"video-postrender-callback=%lld,"
"}",
vcodec,
"no-time-sync",
(long long int)(intptr_t)(void *)&prerender,
(long long int)(intptr_t)(void *)&postrender
);
libvlc_media_add_option(media, options);
auto player = libvlc_media_player_new_from_media(media);
auto eventManager = libvlc_media_player_event_manager(player);
libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, onMediaPlayerEvents, data);
libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, onMediaPlayerEvents, data);
libvlc_event_attach(eventManager, libvlc_MediaPlayerStopped, onMediaPlayerEvents, data);
libvlc_event_attach(eventManager, libvlc_MediaPlayerTimeChanged, onMediaPlayerEvents, data);
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, onMediaPlayerEvents, data);
eventManager = libvlc_media_event_manager(media);
libvlc_event_attach(eventManager, libvlc_MediaParsedChanged, onMediaPlayerEvents, data);
if(!libvlc_media_is_parsed(media))
libvlc_media_parse(media);
// starting
libvlc_media_release(media);
libvlc_media_player_play(player);