[Qt-interest] HOWTO: Grab Video from QMediaPlayer - Solution in Search of a Problem

Atlant Schmidt aschmidt at dekaresearch.com
Tue Sep 21 15:11:22 CEST 2010


Josiah:

  Thanks! Tips and tricks are always appreciated!

                   Atlant

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Josiah Bryan
Sent: Monday, September 20, 2010 16:12
To: 'Qt Interest'
Subject: [Qt-interest] HOWTO: Grab Video from QMediaPlayer - Solution in Search of a Problem

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

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.




More information about the Qt-interest-old mailing list