Unsolved Other option to set media in Player of Qt
-
Hi,
I am able to play .h264 binary file using QMediaPlayer in Qt, but in which I give file from local location using
QMediaPlayer *player; QString fileName = "C:/username/test.mp4"; player->setmedia(QUrl::fromLocalFile(fileName));
Only for knowledge : Second application get data from camera and put frame by frame in .h264 file, and my application read data from this file, for time saving purpose and for better performance, I want to catch direct data from buffer and show on a player.
Now my requirement I have to show on time video of camera, and data come in buffer, so question is, How can I set buffer as a input source of player->setmedia? I don't want to give file location to player->setmedia.
Thanks.
-
Hi,
Is that camera visible from QCamera ?
-
@SGaist : I don't know its visible or not, but in our process, there is RTSP client application which try to get frame from camera and put in a .h264 binary file, now I have to catch frame from RTSP client and show on a player on time.
And ya I can give buffer input to player->setmedia like
mBuffer = new QBuffer(this); const QByteArray &bytArray; mBuffer->write(bytArray); mPlayer->setMedia(QMediaContent(), mBuffer);
Now my question is, can I catch my frame in a bytArray? if yes then will it work continue? means one frame come on bytArray then I have to catch second frame in bytArray again and this process will continue.
-
How are you controlling that RTSP client ? Does it give you access to the frames somehow ?
-
@SGaist : Yes, I can control RTSP client, and this process store frame in a buffer (Char Array). Now I want to show this frame on a screen frame by frame.
-
What format is that frame ?
-
@SGaist : Char array. its a one type of buffer. and ya every frame has different size.
-
My question was more: are you getting a decoded uncompressed frame ?
-
@SGaist : yes I decoded it with system decoder... actually I store buffer in one file, and when I play this file in VLC, it play successfully. but qt show only black screen.
I added some more code...
QMediaPlayer* player[screen]; QVideoWidget* vw[screen]; .... while(1){ if (NULL != fpFrames) { fwrite(u8NAL, 4, 1, fpFrames); fwrite(streamData->dataBuffer, streamData->dataSize, 1, fpFrames); mBuffer->open(QIODevice::ReadWrite); mBuffer->seek(0); mBuffer->setData((char *)streamData->dataBuffer,streamData->dataSize); mBuffer->write((char *)streamData->dataBuffer); mBuffer->seek(0); if(playerFlag == 0){ player[0]->setMedia(QMediaContent(), mBuffer); playerFlag = 1; player[0]->play(); } }
In above code I get data from rtsp in streamData->dataBuffer and its type is void*, I store it in QBuffer *mBuffer, and this mBuffer store in one file, which can play in VLC.
Now when I run this application, application out show some message :
Buffer::setData: Buffer is open*GStreamer; Unable to pause - ""
QBuffer::setData: Buffer is open
QBuffer::setData: Buffer is open
QBuffer::setData: Buffer is open
QBuffer::setData: Buffer is open........*
Now help to come out this problem....
Thanks... -
You never close mBuffer, hence the
Buffer is open
error.