2

我需要在我的程序 (C++) 中嵌入一个视频播放器,但我不能使用 XEmbed,因为我必须进行一些后处理。是否可以像使用 ffmpeg 一样将输出作为原始 RGB 写入内存缓冲区?

4

2 回答 2

5

不幸的是,mplayer 不能作为库运行,但如果您愿意对 mplayer 代码进行一些更改,可能会有一些 hacky 解决方案。这也应该适用于 Windows 和 MacOSX,但需要一些调整。

下载 mplayer 源并查找./libvo/vo_png.c文件。您可以将此文件用作模板并创建自己的(假设)./libvo/vo_shm.c- 有一个获取原始像素的函数。这个想法是创建一个共享内存对象(man shmget)。稍后您可以使用相同的键引用此内存并shmget调用将显示像素缓冲区的其他进程。请注意,您可能应该创建至少两个内存缓冲区,以便一次只有一个进程使用一个缓冲区。甚至三个或更多的缓冲区可能是最佳的。

另外不要忘记更改static const vo_info_t info结构初始化以将视频输出设备注册为不同的名称。据我所知,您的新vo_shm.c产品可以添加到config.mak文件中的构建系统中。

祝你好运。

于 2011-10-05T11:03:01.243 回答
0

许多 Linux 程序都嵌入了 mplayer 播放器(IIRC:gimp-gap、k9copy 等等)

我认为常见的方法是在你的 X 父窗口中嵌入一个来自 mplayer 的子窗口。显然,在 X11 架构上比在 Windows 上更容易实现 :)

man mplayer显示:

 mplayer -wid <windowId>

-guiwid <window id>

 This tells the GUI to also use an X11 window 
 and stick itself to the bottom of the video, 
 which is useful to embed a mini-GUI in a browser 
 (with the mplayerplug-in for instance).

-wid <window id>

 This tells MPlayer to use a X11 window, which is useful 
 to embed MPlayer in a browser (with the plugger extension 
 for instance).

您可以(例如使用 Qt 应用程序)简单地使用

 mplayer -wid mywidget->winId();

所以你只需要

  1. 对 mplayer 的安装依赖
  2. 人 execve/人 mplayer
于 2011-10-05T11:59:26.240 回答