[Qt-interest] HOWTO: Grab Video from QMediaPlayer - Solution in Search of a Problem
Josiah Bryan
jbryan at productiveconcepts.com
Mon Sep 20 22:11:46 CEST 2010
This is just a 'solution' email - no question, no problem - just an
email in case someone else is trying to figure this out, hopefully this
may save someone some time.
I've managed to cobble together a Qt example (don't remember which one)
and some advice on various bulletin boards in order to create a class
that can grab video from QMediaPlayer (from the QtMobility Solution)
without having to render the video on screen first.
Basically, it creates a 'fake' QAbstractVideoSurface - that's easy
enough to do - one of the Qt examples (maybe in the QtMobility examples)
shows you basically how to create a video surface. The magic was the
line someone showed me, basically like this:
QVideoRendererControl* rendererControl =
m_player->service()->requestControl<QVideoRendererControl*>();
if (rendererControl)
rendererControl->setSurface(m_surfaceAdapter);
Basically, it attaches the fake video surface (m_surfaceAdapter) to the
output of the QMediaPlayer object - and voila! We've got video streaming
into our video surface for us to do whatever we want with it. In my
case, I convert each from to a QImage and render into an OpenGL texture
for compositing with various other elements on screen.
(See http://code.google.com/p/dviz/, specifically the latest post on
that page about SVN r664 for an example of the compositing.)
I don't claim to have invented anything new here - just showing a
concrete example of how to put the various bits and pieces together
inorder to achieve the desired result. Note that QMediaPlayer still
handles all the audio paths - I just take the video frames.
(I'm sure if you go digging through *how* I use the video, the
GLDrawable setup, and all the rest of the framework behind LiveMix,
you'll find plenty to criticize or tell me how I can do it better - if
you see anything you want to tell me about, feel free to. Or not. This
is more about the video adapter, not really about how unimaginative of a
coder I am. Thanks for your patience! :-)
Cheers!
-Josiah Bryan
--
-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224
More information about the Qt-interest-old
mailing list