[Interest] [Qt3D] Render to video

Andy asmaloney at gmail.com
Mon Apr 18 14:31:48 CEST 2016


On Mon, Apr 18, 2016 at 2:51 AM, Bo Thorsen <bo at vikingsoft.eu> wrote:

> Den 18-04-2016 kl. 05:46 skrev Andy:
>
>> Goal: generate video with a user-specified resolution, frame rate, &
>> container/codec format from an animation in my Qt3D window
>>
>> (Disclaimer: I've never worked with video files before!)
>>
>> As far as I can tell, Qt doesn't provide a way to generate video files
>> directly, so I think I have to write a series of QImages to disk and use
>> them to generate a video using ffmpeg.  This seems like it will take a
>> large amount of disk space, be pretty heavy on the I/O, and generally be
>> slow.  Are there better solutions?
>>
>> If I need to do it that way though, I must generate QImages from my
>> existing Qt3DCore::QAspectEngine in my QWindow-derived class.  I don't
>> see a clear/elegant way to do this.
>>
>> I think I need to create an offscreen surface? window? with the correct
>> resolution and then somehow render & animate my scene to it, saving
>> snapshots as I move the camera.  (I am already using QAbstractAnimation
>> to move the camera, so I would use it to grab the snapshots as well.)
>> Can I use the same root entity in multiple QAspectEngines? (i.e.
>> setRootEntity() to my root entity in the new offscreen and tell it to
>> render.)
>>
>> Has anyone done this before?  Is this even close to the right approach?
>>
>> (I'm using straight C++ - no QML.)
>>
>
> Why do you want to do this in Qt when you can do it with applications like
> Camtasia?
>

Because I want to generate video from the Qt3D scene in my application?  I
don't understand the question.


> If you do want to follow this, the first part is to just generate
> screenshots. There's an example app in Qt that does this:
> http://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html.
>

I know I can save a widget as an image, but as I said, I need a
user-specified resolution and I need to get the info from the existing Qt3D
scene.  Offscreen seems like the logical solution.  I could (maybe)
duplicate the whole scene in an invisible widget and get images from that,
but that seems like a hack.


>
> Second, find one of the libraries that does video encoding and use your
> screenshots there.
>
> Shouldn't be too hard, but you might have to convert the pixels manually
> to the video library format, so it could be quite slow.
>
> Bo Thorsen,
> Director, Viking Software.
>
> --
> Viking Software
> Qt and C++ developers for hire
> http://www.vikingsoft.eu
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160418/adf91e0b/attachment.html>


More information about the Interest mailing list