How to convert QImage to QVideoFrame so I would set it as frame for VideoSink Qt6.2
-
The app crashes when I try to execute that block of code..
I get the idea but I do not seem to have an implementation of it in mind so far. -
@UbiMiles said in How to convert QImage to QVideoFrame so I would set it as frame for VideoSink Qt6.2:
The app crashes
Did you debug to see where exactly and why it crashes?
-
QImage img( QStringLiteral( "sample_640×426.png" ) ); QVideoFrameFormat fmt( img.size(), QVideoFrameFormat::Format_YUYV ); QVideoFrame vf( fmt ); vf.map( QVideoFrame::WriteOnly ); libyuv::ARGBToYUY2( (const uint8_t*) img.bits(), img.bytesPerLine(), vf.bits( 0 ), vf.bytesPerLine( 0 ), img.width(), img.height() ); vf.unmap();
Only be sure that QImage pixel format is ARGB32...
-
@imironchik My QImage pixel type is RGB888
memcpy managed to get the job done , yet if I try declaring a video frame with the format of my QImage an invalid frame is returned, Explicitly providing the format shows that it does indeed work yet it's messed up do to incompatible formats,I submitted this question on stackoverflow and provided an answer myself, now I am trying to find a way to get it to work with RGB888
https://stackoverflow.com/questions/71407367/how-to-convert-qimage-to-qvideoframe-so-i-would-set-it-as-frame-for-videosink-qt/71409775#71409775 -
@imironchik
I see, thanks
one last question is where is "libyuv" namespace coming from