Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Can't play video using QtWebEngine
Forum Updated to NodeBB v4.3 + New Features

Can't play video using QtWebEngine

Scheduled Pinned Locked Moved Unsolved QtWebEngine
19 Posts 5 Posters 3.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi,

    Without seeing your code, nobody can guess what's going on.

    The first question that comes to mind is: what are you doing differently from the Quick Nano Browser example ?

    Z Offline
    Z Offline
    Zabarne
    wrote on last edited by
    #5

    @SGaist I will prepare a little demo and share it here

    1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Without seeing your code, nobody can guess what's going on.

      The first question that comes to mind is: what are you doing differently from the Quick Nano Browser example ?

      Z Offline
      Z Offline
      Zabarne
      wrote on last edited by Zabarne
      #6

      Good Morning @SGaist

      Here you are:

      #include <QApplication>
      #include <QMainWindow>
      #include <QWebEngineView>
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          QMainWindow* window = new QMainWindow();
          QWebEngineView * view = new QWebEngineView(window);
          window->setCentralWidget(view);
          window->resize(1024, 768);
          window->show();
      
          QWebEnginePage * page = new QWebEnginePage(view);
      
          view->setPage(page);
          view->load(QUrl("https://www.richemont.com/"));
      
          return app.exec();
      }
      

      And as you can see, even with a minimalistic QtWebEngine app, the video isn't loaded:
      richemont.png

      The video is quite big ~40MiB. Is there a QtWebEngine's buffer we can tweak? Not even sure if this is related.

      Help appreciated!

      Z 1 Reply Last reply
      0
      • Z Zabarne

        Good Morning @SGaist

        Here you are:

        #include <QApplication>
        #include <QMainWindow>
        #include <QWebEngineView>
        
        int main(int argc, char **argv)
        {
            QApplication app(argc, argv);
        
            QMainWindow* window = new QMainWindow();
            QWebEngineView * view = new QWebEngineView(window);
            window->setCentralWidget(view);
            window->resize(1024, 768);
            window->show();
        
            QWebEnginePage * page = new QWebEnginePage(view);
        
            view->setPage(page);
            view->load(QUrl("https://www.richemont.com/"));
        
            return app.exec();
        }
        

        And as you can see, even with a minimalistic QtWebEngine app, the video isn't loaded:
        richemont.png

        The video is quite big ~40MiB. Is there a QtWebEngine's buffer we can tweak? Not even sure if this is related.

        Help appreciated!

        Z Offline
        Z Offline
        Zabarne
        wrote on last edited by
        #7

        @SGaist Could you help me please?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ryan.S
          wrote on last edited by Ryan.S
          #8

          I have a custom Qt app that uses a QtWebEngine browser and it can successfully playback the video at the top of the page.

          My QtWebEngine was compiled with proprietary codecs and if I had to guess, this is almost certainly the issue. I'm not knowledgeable enough to know which codecs are included when compiling with proprietary codecs or why QuickNanoBrowser would work...does QuickNanoBrowser perhaps come with an open source codec like OpenH264? According to VLC, the video is using a basic h264 codec.

          The only other thing my app may have that yours might not, is using persistent cookies on the QWebEngineProfile that gets loaded with the browser. Perhaps the site requires something on the cookie-side, but that seems less likely than the codec(s).

          Z 1 Reply Last reply
          1
          • R Ryan.S

            I have a custom Qt app that uses a QtWebEngine browser and it can successfully playback the video at the top of the page.

            My QtWebEngine was compiled with proprietary codecs and if I had to guess, this is almost certainly the issue. I'm not knowledgeable enough to know which codecs are included when compiling with proprietary codecs or why QuickNanoBrowser would work...does QuickNanoBrowser perhaps come with an open source codec like OpenH264? According to VLC, the video is using a basic h264 codec.

            The only other thing my app may have that yours might not, is using persistent cookies on the QWebEngineProfile that gets loaded with the browser. Perhaps the site requires something on the cookie-side, but that seems less likely than the codec(s).

            Z Offline
            Z Offline
            Zabarne
            wrote on last edited by Zabarne
            #9

            Hi @Ryan-S

            @Ryan-S said in Can't play video using QtWebEngine:

            The only other thing my app may have that yours might not, is using persistent cookies on the QWebEngineProfile that gets loaded with the browser.

            This is interesting. Would you mind sharing how to persist cookies with a profile?

            I adapted the above code to use QWebEngineProfile like this:

            #include <QApplication>
            #include <QMainWindow>
            #include <QWebEngineProfile>
            #include <QWebEngineView>
            #include <QNetworkCookie>
            
            int main(int argc, char **argv)
            {
                QApplication app(argc, argv);
            
                QMainWindow* window = new QMainWindow();
                QWebEngineView * view = new QWebEngineView(window);
                QWebEngineProfile * profile = new QWebEngineProfile(view);
                window->setCentralWidget(view);
                window->resize(1024, 768);
                window->show();
            
                QWebEnginePage * page = new QWebEnginePage(profile, view);
                view->setPage(page);
                view->load(QUrl("https://www.richemont.com/"));
            
                return app.exec();
            }
            

            I still doubt this is related to proprietary codecs as QuickNanoBrowser has/does nothing special (a basic app).

            @Ryan-S is there a way to avoid recompiling QtWebEngine with proprietary codecs and still get the proprietary codecs working with my app?

            Recompiling everything is time consuming and require QT/system knowledge. If I can avoid this and still get the codecs working, it would be great.

            Many thanks for your help.

            Z 1 Reply Last reply
            0
            • Z Zabarne

              Hi @Ryan-S

              @Ryan-S said in Can't play video using QtWebEngine:

              The only other thing my app may have that yours might not, is using persistent cookies on the QWebEngineProfile that gets loaded with the browser.

              This is interesting. Would you mind sharing how to persist cookies with a profile?

              I adapted the above code to use QWebEngineProfile like this:

              #include <QApplication>
              #include <QMainWindow>
              #include <QWebEngineProfile>
              #include <QWebEngineView>
              #include <QNetworkCookie>
              
              int main(int argc, char **argv)
              {
                  QApplication app(argc, argv);
              
                  QMainWindow* window = new QMainWindow();
                  QWebEngineView * view = new QWebEngineView(window);
                  QWebEngineProfile * profile = new QWebEngineProfile(view);
                  window->setCentralWidget(view);
                  window->resize(1024, 768);
                  window->show();
              
                  QWebEnginePage * page = new QWebEnginePage(profile, view);
                  view->setPage(page);
                  view->load(QUrl("https://www.richemont.com/"));
              
                  return app.exec();
              }
              

              I still doubt this is related to proprietary codecs as QuickNanoBrowser has/does nothing special (a basic app).

              @Ryan-S is there a way to avoid recompiling QtWebEngine with proprietary codecs and still get the proprietary codecs working with my app?

              Recompiling everything is time consuming and require QT/system knowledge. If I can avoid this and still get the codecs working, it would be great.

              Many thanks for your help.

              Z Offline
              Z Offline
              Zabarne
              wrote on last edited by Zabarne
              #10

              @SGaist @Ryan-S

              I tried with persistent cookies, same result. Can't load this video :-(

              #include <QApplication>
              #include <QMainWindow>
              #include <QWebEngineProfile>
              #include <QWebEngineView>
              #include <QNetworkCookie>
              #include <QStandardPaths>
              
              int main(int argc, char **argv)
              {
                  QApplication app(argc, argv);
              
                  QMainWindow* window = new QMainWindow();
                  QWebEngineView * view = new QWebEngineView(window);
              
                  QWebEngineProfile * profile = new QWebEngineProfile(view);
                  profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
                  profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
                  profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                  profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
              
                  window->setCentralWidget(view);
                  window->resize(1024, 768);
                  window->show();
              
                  QWebEnginePage * page = new QWebEnginePage(profile, view);
                  view->setPage(page);
                  view->load(QUrl("https://www.richemont.com/"));
              
                  return app.exec();
              }
              

              Can someone with good QtWebEngine skills help me understand why?
              Many thanks

              JonBJ M 2 Replies Last reply
              0
              • Z Zabarne

                @SGaist @Ryan-S

                I tried with persistent cookies, same result. Can't load this video :-(

                #include <QApplication>
                #include <QMainWindow>
                #include <QWebEngineProfile>
                #include <QWebEngineView>
                #include <QNetworkCookie>
                #include <QStandardPaths>
                
                int main(int argc, char **argv)
                {
                    QApplication app(argc, argv);
                
                    QMainWindow* window = new QMainWindow();
                    QWebEngineView * view = new QWebEngineView(window);
                
                    QWebEngineProfile * profile = new QWebEngineProfile(view);
                    profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
                    profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
                    profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                    profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
                
                    window->setCentralWidget(view);
                    window->resize(1024, 768);
                    window->show();
                
                    QWebEnginePage * page = new QWebEnginePage(profile, view);
                    view->setPage(page);
                    view->load(QUrl("https://www.richemont.com/"));
                
                    return app.exec();
                }
                

                Can someone with good QtWebEngine skills help me understand why?
                Many thanks

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #11

                @Zabarne
                First things first: please try a variety of web pages with videos. Does the bad behaviour always apply or only to the particular video/site you mention?

                Z 1 Reply Last reply
                0
                • JonBJ JonB

                  @Zabarne
                  First things first: please try a variety of web pages with videos. Does the bad behaviour always apply or only to the particular video/site you mention?

                  Z Offline
                  Z Offline
                  Zabarne
                  wrote on last edited by Zabarne
                  #12

                  Hi @JonB

                  Most websites containing videos work as expected, but this one. This is why I asked for help.

                  When facing issues, I usually compare my app's behavior to QuickNanoBrowser. Till now, I was able to solve them all with my little QT knowledge. But this time, the Richemont video is perfectly working on QuickNanoBrowser but not in my app.

                  I followed @SGaist advice and I provided a minimalistic code to consistently reproduce this behavior on macOS, Windows and Linux (see above).

                  Finally, to my knowledge, QuickNanoBrowser doesn't rely on any proprietary codecs, and is still capable of loading this video.

                  Question: what QuickNanoBrowser does (in terms of enabled/disabled config) that my minimalistic app isn't doing?

                  I must be missing something.

                  Many thanks

                  JonBJ 1 Reply Last reply
                  0
                  • Z Zabarne

                    @SGaist @Ryan-S

                    I tried with persistent cookies, same result. Can't load this video :-(

                    #include <QApplication>
                    #include <QMainWindow>
                    #include <QWebEngineProfile>
                    #include <QWebEngineView>
                    #include <QNetworkCookie>
                    #include <QStandardPaths>
                    
                    int main(int argc, char **argv)
                    {
                        QApplication app(argc, argv);
                    
                        QMainWindow* window = new QMainWindow();
                        QWebEngineView * view = new QWebEngineView(window);
                    
                        QWebEngineProfile * profile = new QWebEngineProfile(view);
                        profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
                        profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
                        profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                        profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
                    
                        window->setCentralWidget(view);
                        window->resize(1024, 768);
                        window->show();
                    
                        QWebEnginePage * page = new QWebEnginePage(profile, view);
                        view->setPage(page);
                        view->load(QUrl("https://www.richemont.com/"));
                    
                        return app.exec();
                    }
                    

                    Can someone with good QtWebEngine skills help me understand why?
                    Many thanks

                    M Offline
                    M Offline
                    mpergand
                    wrote on last edited by mpergand
                    #13

                    @Zabarne
                    It is a mp4 video, as I said earlier, you need to build the webengine yourself and I i'm afraid there's no escape.

                    Trying to read this video I have an error saying my browser is not compatible and needs an update.

                    Z 1 Reply Last reply
                    0
                    • Z Zabarne

                      Hi @JonB

                      Most websites containing videos work as expected, but this one. This is why I asked for help.

                      When facing issues, I usually compare my app's behavior to QuickNanoBrowser. Till now, I was able to solve them all with my little QT knowledge. But this time, the Richemont video is perfectly working on QuickNanoBrowser but not in my app.

                      I followed @SGaist advice and I provided a minimalistic code to consistently reproduce this behavior on macOS, Windows and Linux (see above).

                      Finally, to my knowledge, QuickNanoBrowser doesn't rely on any proprietary codecs, and is still capable of loading this video.

                      Question: what QuickNanoBrowser does (in terms of enabled/disabled config) that my minimalistic app isn't doing?

                      I must be missing something.

                      Many thanks

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #14

                      @Zabarne
                      I don't know whether this helps, but under Ubuntu 22.04, Qt 5.15, which is all I have, the video from that site runs fine in your sample code. The Qt build comes from Ubuntu via apt-get, and I had to go apt-get install qtwebengine5-dev to get the QtWebEngine stuff. I don't know whether Ubuntu does a special build or does "codecs" for that.

                      1 Reply Last reply
                      0
                      • M mpergand

                        @Zabarne
                        It is a mp4 video, as I said earlier, you need to build the webengine yourself and I i'm afraid there's no escape.

                        Trying to read this video I have an error saying my browser is not compatible and needs an update.

                        Z Offline
                        Z Offline
                        Zabarne
                        wrote on last edited by
                        #15

                        @mpergand if it was really the case, how come QuickNanoBrowser can read .mp4 videos?

                        JonBJ 1 Reply Last reply
                        0
                        • Z Zabarne

                          @mpergand if it was really the case, how come QuickNanoBrowser can read .mp4 videos?

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #16

                          @Zabarne
                          I don't know, but compared to QML example do you need to (a) handle any errors (or redirections?) and (b) handle anything to do with SSL (https)?
                          If you run yours, can you press a function key or something to get any diagnostics from your page, e.g. Chrome Developer mode/tools, key F12?

                          1 Reply Last reply
                          0
                          • Z Offline
                            Z Offline
                            Zabarne
                            wrote on last edited by
                            #17

                            Thanks @JonB. Gonna give a try.

                            I hope no breaking changes were introduced in Qt6.x if the video was loaded with old Qt5.15.

                            Keep you posted.

                            SGaistS 1 Reply Last reply
                            0
                            • Z Zabarne

                              Thanks @JonB. Gonna give a try.

                              I hope no breaking changes were introduced in Qt6.x if the video was loaded with old Qt5.15.

                              Keep you posted.

                              SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #18

                              @Zabarne I tested both your code and the Quick Nano Browser example with Qt 6.6.0 on macOS and neither shows the video.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              Z 1 Reply Last reply
                              1
                              • SGaistS SGaist

                                @Zabarne I tested both your code and the Quick Nano Browser example with Qt 6.6.0 on macOS and neither shows the video.

                                Z Offline
                                Z Offline
                                Zabarne
                                wrote on last edited by Zabarne
                                #19

                                Hi guys

                                Now, I'm 100% convinced that this issue was caused by video codecs H264 not supported by default in QtWebEngine.

                                Thanks for your support.

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved