Unsolved 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(); }
-
Hi,
What version of Qt are you using ?
On what OS ? -
5.14 on MacOS.
-
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
-
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!