Вопрос

I need to embed a video player into my program (C++) but I cannot use XEmbed, because I must do some postprocessing. Is it possible to write the output as a raw RGB to a buffer of memory like you can do with ffmpeg?

Это было полезно?

Решение

Unfortunately mplayer cannot run as a library but there might be a bit of a hacky solution if you are willing to do some changes to the mplayer code. This should also work on Windows and MacOSX but needs some adapting.

Download mplayer sources and look-up the ./libvo/vo_png.c file. You can use this file as a template and create your own (let's say) ./libvo/vo_shm.c - there is a function which gets raw pixels. The idea is to create a shared memory object (man shmget). You can later reference this memory by using the same key and shmget call in the other process that is gonna display the pixel buffer. Note that you should probably create at least two memory buffers so that at one time only one process uses one buffer. Maybe even three or more buffers would be optimal.

Also don't forget to change static const vo_info_t info struct initialization to register the video output device as a different name. Your new vo_shm.c can be added to the build system in config.mak file as far as I can see.

Good luck.

Другие советы

Lots of Linux programs embed a mplayer player (IIRC: gimp-gap, k9copy among many others)

I think the common approach is to embed a child window from mplayer right inside your X parent window. Obviously that is more readily achieved on the X11 architecture than on windows :)

man mplayer shows:

 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).

You could (e.g. using a Qt application) simply use

 mplayer -wid mywidget->winId();

So all you'd need is

  1. a installation dependency on mplayer
  2. man execve/man mplayer
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top