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 Update on Monday, May 27th 2025

Can't play video using QtWebEngine

Scheduled Pinned Locked Moved Unsolved QtWebEngine
19 Posts 5 Posters 3.4k Views
  • 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.
  • Z Offline
    Z Offline
    Zabarne
    wrote on 19 Nov 2023, 17:35 last edited by Zabarne
    #1

    Hi guys

    While I'm able to watch the video in this website with using QuickNanoBrowser:
    https://www.richemont.com/
    quicknanobrowser.png

    I'm unable to load it with my QtWebEngine based app:

    my_app_based_webengine.png

    Is there any reason for that? Is there anything to enable to let the video displays?
    I'm on macOS / QT6.6.0.

    Help appreciated
    Many thanks

    M 1 Reply Last reply 19 Nov 2023, 21:17
    1
    • Z Zabarne
      19 Nov 2023, 17:35

      Hi guys

      While I'm able to watch the video in this website with using QuickNanoBrowser:
      https://www.richemont.com/
      quicknanobrowser.png

      I'm unable to load it with my QtWebEngine based app:

      my_app_based_webengine.png

      Is there any reason for that? Is there anything to enable to let the video displays?
      I'm on macOS / QT6.6.0.

      Help appreciated
      Many thanks

      M Offline
      M Offline
      mpergand
      wrote on 19 Nov 2023, 21:17 last edited by mpergand
      #2

      Hi @Zabarne,

      I have the same thing, I suppose this video uses some mpg formats, QWebEngine needs to be build with Proprietary codecs enabled .
      See HERE

      Z 1 Reply Last reply 20 Nov 2023, 19:27
      0
      • M mpergand
        19 Nov 2023, 21:17

        Hi @Zabarne,

        I have the same thing, I suppose this video uses some mpg formats, QWebEngine needs to be build with Proprietary codecs enabled .
        See HERE

        Z Offline
        Z Offline
        Zabarne
        wrote on 20 Nov 2023, 19:27 last edited by Zabarne
        #3

        Hi @mpergand

        Thanks for your help.

        If it was really a proprietary audio/video CODEC issue, why the QuickNanoBrowser app shipped with QTCreator worked?

        To my knowledge, QT team doesn't provide any proprietary CODEC.
        If the QuickNanoBrowser app failed to load the video, I would have agreed with you. But this isn't the case and the video was sucessfully loaded in QuickNanoBrowser (see above screenshot),

        Best

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Nov 2023, 19:47 last edited by
          #4

          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 ?

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

          Z 2 Replies Last reply 21 Nov 2023, 00:06
          0
          • S SGaist
            20 Nov 2023, 19:47

            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 21 Nov 2023, 00:06 last edited by
            #5

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

            1 Reply Last reply
            0
            • S SGaist
              20 Nov 2023, 19:47

              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 21 Nov 2023, 09:21 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 22 Nov 2023, 17:07
              0
              • Z Zabarne
                21 Nov 2023, 09:21

                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 22 Nov 2023, 17:07 last edited by
                #7

                @SGaist Could you help me please?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Ryan.S
                  wrote on 22 Nov 2023, 19:10 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 22 Nov 2023, 20:16
                  1
                  • R Ryan.S
                    22 Nov 2023, 19:10

                    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 22 Nov 2023, 20:16 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 23 Nov 2023, 09:04
                    0
                    • Z Zabarne
                      22 Nov 2023, 20:16

                      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 23 Nov 2023, 09:04 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 23 Nov 2023, 09:29
                      0
                      • Z Zabarne
                        23 Nov 2023, 09:04

                        @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 23 Nov 2023, 09:29 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 23 Nov 2023, 09:48
                        0
                        • JonBJ JonB
                          23 Nov 2023, 09:29

                          @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 23 Nov 2023, 09:48 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 23 Nov 2023, 10:10
                          0
                          • Z Zabarne
                            23 Nov 2023, 09:04

                            @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 23 Nov 2023, 09:52 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 23 Nov 2023, 11:51
                            0
                            • Z Zabarne
                              23 Nov 2023, 09:48

                              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 23 Nov 2023, 10:10 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
                                23 Nov 2023, 09:52

                                @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 23 Nov 2023, 11:51 last edited by
                                #15

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

                                JonBJ 1 Reply Last reply 23 Nov 2023, 12:28
                                0
                                • Z Zabarne
                                  23 Nov 2023, 11:51

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

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on 23 Nov 2023, 12:28 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 23 Nov 2023, 15:08 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.

                                    S 1 Reply Last reply 23 Nov 2023, 19:44
                                    0
                                    • Z Zabarne
                                      23 Nov 2023, 15:08

                                      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.

                                      S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 23 Nov 2023, 19:44 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 25 Nov 2023, 02:18
                                      1
                                      • S SGaist
                                        23 Nov 2023, 19:44

                                        @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 25 Nov 2023, 02:18 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

                                        1/19

                                        19 Nov 2023, 17:35

                                        • Login

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