Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Other option to set media in Player of Qt
Qt 6.11 is out! See what's new in the release blog

Other option to set media in Player of Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tejas Virpariya
    wrote on last edited by
    #1

    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.

    -Thanks
    Tejas Patel

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Is that camera visible from QCamera ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Is that camera visible from QCamera ?

        T Offline
        T Offline
        Tejas Virpariya
        wrote on last edited by
        #3

        @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.

        -Thanks
        Tejas Patel

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How are you controlling that RTSP client ? Does it give you access to the frames somehow ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          0
          • SGaistS SGaist

            How are you controlling that RTSP client ? Does it give you access to the frames somehow ?

            T Offline
            T Offline
            Tejas Virpariya
            wrote on last edited by
            #5

            @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.

            -Thanks
            Tejas Patel

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What format is that frame ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              0
              • SGaistS SGaist

                What format is that frame ?

                T Offline
                T Offline
                Tejas Virpariya
                wrote on last edited by
                #7

                @SGaist : Char array. its a one type of buffer. and ya every frame has different size.

                -Thanks
                Tejas Patel

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  My question was more: are you getting a decoded uncompressed frame ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Tejas Virpariya
                    wrote on last edited by
                    #9

                    @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...

                    -Thanks
                    Tejas Patel

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      You never close mBuffer, hence the Buffer is open error.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved