I looked into Micheal's solution and it's clever. However I would try a few things:
1. Use QImage's QImage::Format_RGB888, and use scanLine() to dump the image line by line to stdout. (Scanline is so much faster)
2. Try to paralellize it. Perhaps you have X cores, start X processes, offset each instance 1 frame from the previous and then render every Xth frame.
3. Avoiding IO might be slower than doing the additional IO. You lock yourself into a single thread, and can't scale. Meanwhile you could write another process to grab frames from disk (only waiting when the frame has been rendered) and feeding them into ffmpeg. Try a different format, either raw write the scanlines, or use BMP to bypass the compression of PNG. Ideally, it would render 1,2,3,4 and you'd add 1,2,3,4, but it will get out of sync, like 4,1,2,3. But So you'll wait for 1, then immediately add 1,2,3, But you'll be rendering X times the frames in the same time.
 
I'd write the additional code so you can scale. Then you use the cloud (assuming FBO) works on one of theose 36-core amazon instances and render in soft-realtime (assuming 30fps). 
 
 
Sent: Monday, April 18, 2016 at 10:13 AM
From: Andy <[email protected]>
To: "Jason H" <[email protected]>
Cc: "Qt Project" <[email protected]>
Subject: Re: [Interest] [Qt3D] Render to video
On Mon, Apr 18, 2016 at 10:00 AM, Jason H <[email protected]> wrote:
I did something like this a long time ago in QML (Before Qt3D, QtQuick 1):
1. There is some kind of frame advance, so you set up the animations as you want, then you start the animation and render the first frame to an image. Then call frame advance and get the next frame, repeat.
2. Then use FFMPeg to create the video from the PNG/JPG files.
 
A couple of pointers:
1. Use a multithreaded image saver. I was Passign QPixmap/QImage to a thread for saving to PNG and the compression time was horrendous. Being able to tap into all the CPUs scaled linearly. (I was rendering 1920x1080 about 6 years ago)
2. You might have to restrict yourself to a raster painter (if such an option still exists)


Thanks Jason.

I'm hoping I can tap into the Qt3D FBO (Sean's suggestion) and pipe the data directly to ffmpeg (Michael's suggestion) which would avoid all that I/O.  Hardware encoding would also be nice, but first things first!
 
 
Sent: Sunday, April 17, 2016 at 11:46 PM
From: Andy <[email protected]>
To: "Qt Project" <[email protected]>
Subject: [Interest] [Qt3D] Render to video
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.)
 
Thanks!
 
---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to