How to Stream live youtube video in qml ?



  • Hello , how can i view live videostream from youtube in Qtwebview or Qwebengineview ?

    when i try i get this error :
    alt text

    but normal videos play fine

    alt text

    what should i do ?


  • Lifetime Qt Champion

    Hi,

    Likely related to the use of proprietary codecs. See here for enabling them for QtWebengine.



  • Hi , i have this simple qml file where i want to play the video

    import QtQuick 2.0
    import QtWebView 1.1
    
    Item {
    
    
        WebView {
            id: webView
            anchors.fill: parent
            url: "https://www.youtube.com/embed/K-heSQmydtE?&autoplay=1&rel=0&showinfo=0&hd=1&autohide=1"
    
        }
    }
    
    

    how can i do that in this file i.e. in qml webview


  • Lifetime Qt Champion

    How can you do what ?



  • @SGaist

    I will try to explain myself properly this time :)

    Okay the idea is to play a live youtube video in webview ( QML webview not the Qtwebview or WebEngine)

    Normal youtube videos are playing fine . You can see it in below gif
    alt text

    This is the qml code i am using to play the video

    import QtQuick 2.0
    import QtWebView 1.1
    
    Item {
        WebView {
            id: webView
            anchors.fill: parent
            url : "https://www.youtube.com/embed/fWRISvgAygU"
        }
    }
    
    

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QQmlContext>
    #include <QSettings>
    #include <QQuickStyle>
    #include <QtWebView/QtWebView>
    int main(int argc, char *argv[])
    {
    
         QGuiApplication app(argc, argv);
        QtWebView::initialize();
        QSettings settings;
        QString style = QQuickStyle::name();
        if (!style.isEmpty())
            settings.setValue("style", style);
        else
            QQuickStyle::setStyle(settings.value("style").toString());
    
        QQmlApplicationEngine engine;
        engine.load(QUrl("qrc:/main.qml"));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    
    

    now if i try with live stream video this is the output
    alt text

    the code is same as above .

    Now my question is : how can i play livestream youtube video in my application .



  • I don't think it is the codecs (first video plays just fine) but probably related to the format in which it is served by YouTube
    I did a quick test (with youtube-dl) and apparently what is served is not actually a live stream but looks more like a playlist (for your browser to choose from) - see below .../playlist/index.m3u8 and you probably will need a plugin for that

    youtube-dl.exe "https://www.youtube.com/embed/K-heSQmydtE?&autoplay=1&rel=0&showinfo=0&hd=1&autohide=1"
    ...
    Input #0, hls,applehttp, from 'https://manifest.googlevideo.com/api/manifest/hls_playlist/id/K-heSQmydtE.1/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r3---sn-vgqs7nl7.googlevideo.com/ei/WcxTWbK5C4f-uALhy4yADQ/gcr/us/playlist_type/LIVE/mm/32/mn/sn-vgqs7nl7/ms/lv/mv/m/pl/19/dover/6/mt/1498663937/ip/96.70.38.41/ipbits/0/expire/1498685624/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,gcr,playlist_type,mm,mn,ms,mv,pl/signature/5EFEF37A8C7DBC1EBA68E98ABB1DDD5BE932BBDD.603E8182D4E76E46706B3B748345D32853B18CA1/key/dg_yt0/playlist/index.m3u8':
    ...
    

    Just to make sure it is not the codecs or the fact that it is live - can you test with a real live stream - and I mean single stream and streamed properly
    ex. use any of the live streams here - if these play properly then it is the index.m3u8 - and you probably need plugin capable of handling *.m3u format
    https://testyourmight.com/streams/3.tru3ta1ent.48286022/stream

    ...or if someone knows if there is an option that could be passed (URL key-value pair) that tells YouTube to use different or alternative format avoiding the playlist.



  • @ThatDud3 For the link that you have shared i get following .

    alt text



  • Sorry, I didn't realize they require flash - you can try any other LIVE stream that doesn't have a playlist (and doesn't require a player) - just to make sure it is not a codec issue... now the problem is almost all sites provide an option to choose the quality (or which camera to watch) and provide so called playlist (m3u8, isvm etc.) files

    try to test with other LIVE streams e.g.
    http://www.cbc.ca/player/play/884139075871

    http://www.cput.ac.za/templates/cput_live/testing.php

    or you can try any free web cam live feed - but be carerful these sometimes install their own players or use weird codecs anyway (test in your browser first)
    http://www.ttrix.com/apple/iphone/ipvision/ipvisionpubcameras.html
    http://www.earthcam.com/network/
    http://www.earthcam.com/usa/newyork/timessquare/?cam=tsnorth_hd



  • Hey man it's solved now . I build the apk in release mode and it worked .

    So finally it's working on android but not on desktop .


Log in to reply
 

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