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. Play 1920X1280 mp4 video too slow in QT
Forum Updated to NodeBB v4.3 + New Features

Play 1920X1280 mp4 video too slow in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.1k 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.
  • H Offline
    H Offline
    hitbuyi
    wrote on last edited by hitbuyi
    #1

    with no Qt enviorment, playing mp4 with openCV is fast and normal, in Qt environment, paying mp4 with 1920X1280 pixels is too slow, how to speed up?
    thanks a lot

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

      Hi,

      What version of Qt ?
      What OS ?
      What device ?

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

      H 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What version of Qt ?
        What OS ?
        What device ?

        H Offline
        H Offline
        hitbuyi
        wrote on last edited by hitbuyi
        #3

        @SGaist Qt5.9.9+VS2015(x64) +OpencV4.11, HP notebook,
        first I use 32bit version, too slow, and then change to 64bit version, a bit faster, but it is not faster as normal speed

        jsulmJ 1 Reply Last reply
        0
        • H hitbuyi

          @SGaist Qt5.9.9+VS2015(x64) +OpencV4.11, HP notebook,
          first I use 32bit version, too slow, and then change to 64bit version, a bit faster, but it is not faster as normal speed

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @hitbuyi said in Play 1920X1280 mp4 video too slow in QT:

          HP notebook

          Which does not provide much information about the hardware.
          And you also did not say which OS.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply
          0
          • jsulmJ jsulm

            @hitbuyi said in Play 1920X1280 mp4 video too slow in QT:

            HP notebook

            Which does not provide much information about the hardware.
            And you also did not say which OS.

            H Offline
            H Offline
            hitbuyi
            wrote on last edited by
            #5

            @jsulm Qt5.9.9+VS2015(x64) +OpencV4.11,
            Windows 10(x64 OS), SSD hard disk, 8.0G RAM
            Intel i5-8265 CPU @1.60GHz,1.80GHz

            avi video can play normally, it is very slow to play large mp4 video, I have loaded opencv_videoio_ffmpeg420.dll already

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

              How exactly are you playing these videos ?
              What do you mean by large ?

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

              H 1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                Are you playing the debug or release version of the program?

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                H 1 Reply Last reply
                0
                • SGaistS SGaist

                  How exactly are you playing these videos ?
                  What do you mean by large ?

                  H Offline
                  H Offline
                  hitbuyi
                  wrote on last edited by SGaist
                  #8

                  @SGaist openCV, code as following

                  void  videoView::showVideo_1Frm(std::string filePath, int iFrm) {
                  	cv::Mat frame;
                  	cv::VideoCapture capture(filePath); // read video indicated by filePath
                  	cv::VideoCapture *pV = NULL;
                  
                  	if (!capture.isOpened()) {
                  		openVideo(filePath);
                  	}
                  	if (capture.isOpened()) {
                  	if(filePath.length() > 0){
                  		pV = &capture;
                  		(*pV).set(cv::CAP_PROP_POS_FRAMES, iFrm );
                  		(*pV) >> frame; 
                       
                  		if (!frame.empty()) {
                              #if 1
                  			cv::cvtColor(frame, frame, CV_BGR2RGB);
                  			cv::resize(frame, frame, cv::Size(640, 480));
                  			QImage image((const uchar*)frame.data, frame.cols, frame.rows, QImage::Format_RGB888);
                  			ui->LVideo->setPixmap(QPixmap::fromImage(image));
                  			ui->LVideo->resize(ui->LVideo->pixmap()->size());
                  			ui->LVideo->show();
                              #endif 
                  		}
                  	}
                  	else {
                  		std::cout << "loading error,please check the path" << std::endl;
                  	}
                  }
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    That code is for showing one frame, you are not playing the video.

                    Note there are several issues with this code.

                    • pV is useless.
                    • you check that your capture is opened while it clearly can't since you just created that object.
                    • later on, if the capture is opened, you do a check for the file name length. This one is wrongly located. If the capture opened successfully, it already means that the file name length is not zero.

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

                    H 1 Reply Last reply
                    0
                    • VRoninV VRonin

                      Are you playing the debug or release version of the program?

                      H Offline
                      H Offline
                      hitbuyi
                      wrote on last edited by
                      #10

                      @VRonin both debug and release version are tested,no obvious difference

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        That code is for showing one frame, you are not playing the video.

                        Note there are several issues with this code.

                        • pV is useless.
                        • you check that your capture is opened while it clearly can't since you just created that object.
                        • later on, if the capture is opened, you do a check for the file name length. This one is wrongly located. If the capture opened successfully, it already means that the file name length is not zero.
                        H Offline
                        H Offline
                        hitbuyi
                        wrote on last edited by hitbuyi
                        #11

                        @SGaist

                        1. It shows one frame, with increasing of iFrm, the program plays video
                        2. I have tried openning the video file only one time, deleting pV, no checking of filepath, no more fast speed is obtained;
                        3. when I converted the video format from mp4 to avi , it is more fast obviously, though opencv_videoio_ffmpeg420_64.dll is used in program.
                          MP4 is 20G, avi is 5G
                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          And you want to play that movie in real time frame by frame using OpenCV ?

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

                          H 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            And you want to play that movie in real time frame by frame using OpenCV ?

                            H Offline
                            H Offline
                            hitbuyi
                            wrote on last edited by
                            #13

                            @SGaist yes, you can consider it as playing a mp4 video

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

                              That's one of the issue: formats like mp4 are not sequences of full images but what you are doing here with OpenCV is to ask for each fully decoded frame hence the slowness of the operation.

                              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