简体   繁体   中英

How to run qt application on GPU and not on CPU

I have a small QT application that plays a video from local storage, when I run it video is blocking and slow, I'm using gstreamer 0.1... But when I run it from terminal and explicitly say with gstreamer to run on gpu it works fine.

How can I adjust my code that it runs on GPU from QT... Sample of my code...

    QApplication app(argc, argv);

    QGraphicsView *graphicsView = new QGraphicsView;
    QMediaPlayer *player = new QMediaPlayer;
    QGraphicsScene *scene = new QGraphicsScene;

    graphicsView->setScene(scene);
    graphicsView->setMinimumSize(800,480);
    QGraphicsVideoItem *item = new QGraphicsVideoItem;
    player->setVideoOutput(item);
    graphicsView->scene()->addItem(item);
    graphicsView->show();
    player->setMedia(QUrl::fromLocalFile("/path/to/my/file"));

    QTransform mirror;
    mirror.scale(-1,1);
    item->setTransform(mirror);

    player->play();

return app.exec();

}

You can not use GPU (or switch between CPU and GPU) to run your Qt app. You still need CPU to run your app. GPU isn't general processor: you can only dedicate some math tasks for your GPU. It's CPU controls what will be performed on GPU.

All GStreamer code is executed by CPU. Some elements, however, can use GPU for their internal math. What do you mean under "explicitly say with gstreamer to run on GPU"?

You should only use GStreamer 1.x branch with Qt. GStreamer 0.1 is 15 years old.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM