Play 1920X1280 mp4 video too slow in QT
-
Hi,
What version of Qt ?
What OS ?
What device ? -
@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@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. -
@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. -
How exactly are you playing these videos ?
What do you mean by large ? -
@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; } }
-
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.
-
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.
- It shows one frame, with increasing of iFrm, the program plays video
- I have tried openning the video file only one time, deleting pV, no checking of filepath, no more fast speed is obtained;
- 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
-
And you want to play that movie in real time frame by frame using OpenCV ?
-
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.