Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMedia and RTMP Sources



  • I am looking for a sample project that displays video from a RTMP Stream.
    This project works for a local MP4 but not from a valid RTMP source:

    my .pro file:

    QT       += core gui widgets multimedia multimediawidgets
    TARGET = testApp
    TEMPLATE = app
    SOURCES += main.cpp
    

    My main.cpp file:

    #include <QApplication>
    #include <QMainWindow>
    #include <QVideoWidget>
    #include <QMediaPlayer>
    #include <QMediaPlaylist>
    
    int main(int argc, char * argv[])
    {
    
        QApplication testApp(argc, argv);
        QMainWindow w;
        QVideoWidget videoWidget(&w);
        w.setCentralWidget(&videoWidget);
        QMediaPlayer *player = new QMediaPlayer(&w);
        QMediaPlaylist *playlist = new QMediaPlaylist;
    
        // - THIS WORKS:
        playlist->addMedia(QUrl( QUrl::fromLocalFile("/Users/erik/Desktop/vivoh/movies/jamie.mp4") ));
    
        // - THIS DOES NOT (URL DOES WORK IN VLC)
        //playlist->addMedia(QUrl("rtmp://10.0.0.214/live/stream"));
    
        playlist->setCurrentIndex(1);
        player->setPlaylist(playlist);
        player->setVideoOutput(&videoWidget);
        w.show();
        player->play();
    
        return testApp.exec();
    }
    
    
    

  • Lifetime Qt Champion

    Hi,

    What version of Qt are you using ?
    On what OS ?



  • 5.14 on MacOS.
    Screen Shot 2020-03-15 at 3.46.57 PM.png


  • Lifetime Qt Champion

    That is the information about Qt Creator, not the version of Qt you are using to build your application.



  • Qt/5.14.1/clang_64


  • Lifetime Qt Champion

    Ok, my bad, I mixed rtmp with another protocol. It seems that AVFoundation does not support it. You might want to use VLC and its Qt integration. It provides a wider range of supported codec and protocols than native APIs.



  • Roger that. Thank you!


Log in to reply