Important: Please read the Qt Code of Conduct -

QVideoProbe not emitting videoFrameProbed signal

  • I am attempting to use a QVideoProbe to get frames from a QMediaPlayer which then plays to a QVideoWidget for the user to see. I have tried example code from the documentation and my own code, neither appears to emit the videoFrameProbed event.

    My Code:

    Setting up the signals/slots and objects

    	// Set up video probe (for processing frames)
    	myVideoProbe = new QVideoProbe;
    	connect(myVideoProbe, &QVideoProbe::videoFrameProbed, this, &MotionDetection::processVideoFrame);
    	if (!myVideoProbe->setSource(myVideoPlayer)) {
    		qDebug() << "Failed to set VideoProbe source.";
    	// Set up QVideoWidget
    	myVideoWidget = new QVideoWidget();
    	// Connect video player and video widget
    	connect(myVideoPlayer, &QMediaPlayer::mediaStatusChanged, this, &MotionDetection::repeatVideo);
    	// Play video

    The processVideoFrame slot

    void MotionDetection::processVideoFrame(QVideoFrame frame)
    	qDebug() << " Processing video frame";

    My MainWindow class

    class MotionDetection : public QMainWindow
    	MotionDetection(QWidget *parent = Q_NULLPTR);
    public slots:
    	void chooseVideoFile();
    	void repeatVideo(QMediaPlayer::MediaStatus newMediaStatus);
    	void processVideoFrame(QVideoFrame frame);
    	QMediaPlayer* myVideoPlayer = nullptr;
    	QVideoWidget* myVideoWidget = nullptr;
    	QVideoProbe* myVideoProbe = nullptr;
    	QVideoFrame* lastProcessedFrame = nullptr;
    	QString currentVideoToProcess;
    	Ui::MotionDetectionClass ui;

  • Lifetime Qt Champion

    Hi and welcome to the forums
    What platform/Os and Qt version?
    Does the video the play.
    Can it generally play videos?

  • Thanks, I am using Qt 5.12 on Windows 10. The video does play in the QVideoWidget I am using K-Lite Codec for MP4 Playback. I am compiling with Microsoft Visual Studios 2017 using the Qt Plugin/Extension.

  • Lifetime Qt Champion

    Ok. super.
    and you check myVideoProbe->setSource so it should be supported by the backbone.
    Im not sure what could be wrong.

    if no suggestions show up. ( give it some hours, people are in different time zones)
    then maybe
    can be used.

  • @mrjj Okay, thank you! I have already looked into the possible option of using a QAbstractVideoSurface for this scenario due to this issue. I have been stuck on it all day and I as well have no clue what's wrong, I've tried with different video files, without setting a video output and many other small one line changes I can think of. I do hope for a solution involving the QVideoProbe still as using QAbstractVideoSurface would be unfavorable (but still doable) in my scenario.

  • Lifetime Qt Champion

    I have seen other posts where probe didn't fire.
    I looked around

    but i did not any checks or conditions to explain why it would not.

    You seem to check in the right places so i will assume code is right and it simply do not trigger.

  • I have decided to use OpenCV instead for my image processing, it is more appropriate for in-depth image processing anyway, I believe. If anyone does find a solution to this problem later down the road please feel free to post it! I'm sure it'll help someone.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Not all backends support all feature. Here you have a matrix of the features per backend for Qt 5.11. I believe that it's still accurate for 5.12.

Log in to reply