QML video element could not read from resource



  • I am trying to stream two different videos into my QML application. The first, is NTSC, and I get through /dev/video1 and I can see it being successfully displayed in VLC.
    @
    Video {
    id: camera1
    autoLoad: true
    playing: true
    source: "/dev/video1"
    onStarted: {
    camera1.play()
    }
    }
    @
    When I try to make a video element with it, I get the error "Could not read from resource."

    The other is an RTSP stream, which occasionally outputs video, but often crashes the application.
    @
    Video {
    id: cameraChoice
    autoLoad: true
    playing: true
    source: "rtsp://172.31.0.200/stream1"
    onStarted: {
    cameraChoice.play()
    }
    }
    @
    Sometimes it works, and outputs the video it is given. Other times, it will crash and report "The program has unexpectedly finished." This happens both after a mere half second of the program running, and after successfully starting and then switching to a view that contains the video if the application has been running for less than 5 seconds.

    In addition, even if you do wait and get to it with video displaying, when you switch to a new view, the video remains there for over a second while the tab content behind it changes, before it finally disappears.

    Searching around, I could find no information on why the NTSC connection through video could not be read. In the case of the RTSP stream, I found a report of a bug with RTSP crashing https://bugreports.qt-project.org/browse/QTBUG-21501

    I tried to follow the suggestions of the bug report as below, changing graphics and using a QGL widget, however neither worked.
    @
    int main(int argc, char *argv[])
    {

    QApplication a(argc, argv);
    
    // Use a raster graphics system
    QApplication::setGraphicsSystem("raster"); // You can also try "opengl" here
    
    MainWindow w;
    w.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    w.setViewport(new QGLWidget);
    
    w.setSource(QUrl::fromLocalFile(contentPath + "/main.qml"));
    w.show();
    return a.exec();
    

    }
    @

    Does anyone know whether these two problems are both tied to the video widget, and how to fix them so that I can get video to be read and displayed consistenly?



  • Don't you need to add port to the rtsp source ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.