Unsolved How to play raw video data in Qt
-
Hi, i am new to Qt and i want to know how can i play a raw video(.yuv) frames by frame in qt, i don't want to pass the file path or url to qt, just the buffer containing video data.
Thanks in advance -
Hi and welcome to devnet,
How are you getting the data from the video file ?
-
Thanks for the reply @SGaist.
Actually i am having a ts stream(which contains my video), which i am decoding externally and not in Qt, the decoded output i am taking in buffer and want to pass that buffer to Qt. -
What format is that buffer ?
What library are you using to decode the file ? -
Hi @SGaist ,
-> raw video data format is yuv420p.
-> i am going to use libavcodec(FFmpeg) to decode the file.I tried a small sample yesterday but couldn't get on how to set the raw data format, here it is:
int main(int argc, char *argv[]) { QApplication a(argc, argv); QFile file("/out.yuv"); //this is just for sample, will not be there in actual app file.open(QIODevice::ReadOnly); QByteArray arr = file.readAll(); QMediaPlayer *player = new QMediaPlayer(&a); QBuffer *buffer = new QBuffer(player); buffer->setData(arr); buffer->open(QIODevice::ReadOnly); player->setMedia(QMediaContent(),buffer); player->play(); return a.exec(); }
-
Then also use it to convert the YUV frame into an RGB frame. Or maybe consider the QtAV project.
-
Or, to use the libvlc wrappers, e.g. vlc-qt