On Monday 18 April 2016 15:46:14 Harald Vistnes wrote: > If anyone try out Sean's suggestion and get it to work, it would be great > it they share an example so we don't all have to reinvent the wheel :)
Or even better, contribute it to Qt 3D so everyone can benefit from it out of the box. :) Cheers, Sean > > Harald > > 2016-04-18 15:28 GMT+02:00 Andy <[email protected]>: > > On Mon, Apr 18, 2016 at 9:05 AM, Sean Harmer <[email protected]> wrote: > >> Hi, > >> > >> I think it's possible, although it's not an out of the box feature yet, > >> as > >> Harald pointed out. > >> > >> Have a look into this kind of approach: > >> > >> * Implement something similar to the Scene3DItem that allows to embed Qt > >> 3D > >> into a Qt Quick 2 scene > > > > Thanks Sean. I wouldn't have thought to go through Qt Quick since I've > > never used it and it's not on my radar. > > > >> * This requires using a little bit of private (for now) API to feed the > >> Qt 3D > >> renderer your own OpenGL context and to ask it to render when needed. > >> > >> * Use an FBO (as the Scene3D item does) as the render target - take care > >> to > >> tell the framegraph the size of this "external" render target. > >> > >> * Then, once the scene is rendered on your custom context, either: > >> > >> a) use glReadPixels to grab the contents of the texture you attached to > >> the > >> FBO and pass it to a software encoder. > >> > >> or > >> > >> b) use the texture id to pass the data to a hardware encoder such as > >> nvenc > >> without needing a round trip from the GPU->CPU->GPU. > >> > >> I think that can be made to work. > > > > nvenc looks like it would be a big win for those with NVIDIA cards, and I > > see AMD has the analogous VCE. > > > > > > Thanks everyone for helping me get a better sense of the problem I'm > > trying to solve! > > > >> Cheers, > >> > >> Sean > >> > >> On Monday 18 April 2016 08:38:21 Andy wrote: > >> > On Mon, Apr 18, 2016 at 3:26 AM, Harald Vistnes < > >> > >> [email protected]> > >> > >> > wrote: > >> > > Hi Andy, > >> > > > >> > > An alternative is to use the FFMPEG encoding library instead of the > >> > > command line tools. Then you can pass each frame to the video encoder > >> > >> as > >> > >> > > you generate it without writing them all to disk first. > >> > > >> > This is non-GPL software, so I can't use the lib directly (I should > >> > have > >> > mentioned that). I haven't found a BSD or MIT lib that encodes the > >> > >> common > >> > >> > formats - is anyone aware of one? > >> > > >> > > The natural way to generate the QImages would be to render to an > >> > >> offscreen > >> > >> > > surface of the desired resolution, and then pass each frame to the > >> > >> video > >> > >> > > encoder. > >> > > >> > Great - so I'm on the right track! > >> > > >> > > Unfortunately, reading back the content of offscreen surfaces is > >> > >> missing > >> > >> > > in Qt3D. According to these it will not come before 5.8. > >> > > > >> > > https://bugreports.qt.io/browse/QTBUG-52136 > >> > > https://bugreports.qt.io/browse/QTBUG-52074 > >> > > > >> > > So AFAIK we just have to wait with generating images and videos with > >> > >> Qt3D. > >> > >> > Thanks Harald. Your report is exactly what I'm looking for... That's > >> > unfortunate though - a real showstopper. > >> > > >> > > Cheers, > >> > > Harald > >> > > > >> > > 2016-04-18 5:46 GMT+02:00 Andy <[email protected]>: > >> > >> 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 <https://twitter.com/asmaloney> > >> > >> > >> > >> > >> > >> _______________________________________________ > >> > >> Interest mailing list > >> > >> [email protected] > >> > >> http://lists.qt-project.org/mailman/listinfo/interest > >> > > >> > --- > >> > Andy Maloney // https://asmaloney.com > >> > twitter ~ @asmaloney <https://twitter.com/asmaloney> > >> > >> -- > >> Dr Sean Harmer | [email protected] | Managing Director UK > >> KDAB (UK) Ltd, a KDAB Group company > >> Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090 > >> Mobile: +44 (0)7545 140604 > >> KDAB - Qt Experts > > > > --- > > Andy Maloney // https://asmaloney.com > > twitter ~ @asmaloney <https://twitter.com/asmaloney> -- Dr Sean Harmer | [email protected] | Managing Director UK KDAB (UK) Ltd, a KDAB Group company Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090 Mobile: +44 (0)7545 140604 KDAB - Qt Experts _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
