<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does]]></title><description><![CDATA[<p dir="auto">Hello!<br />
I'm trying to stream an IP camera, but the application output window first displays a warning:<br />
<strong>W/qt.multimedia.ffmpeg.mediadataholder(14712): Failed to open media file. FFmpeg error description: Invalid data encountered while processing input.</strong></p>
<p dir="auto">Then, in onErrorOccurred, I get the error:<br />
<strong>E/qml(14712): MediaPlayer Error: 2 Failed to open file.</strong><br />
Here's my code:</p>
<pre><code>...
                   MediaPlayer {
                        id: mediaPlayer

                        source:  "https://cdn.some_domen/.../stream.m3u8?uuid=some_uuid&amp;token=some_token"
                        videoOutput: videoOutput
                        audioOutput: AudioOutput {}

                        onErrorOccurred: {
                            console.error("MediaPlayer error:", mediaPlayer.error, mediaPlayer.errorString);
                        }
                    }

                    VideoOutput {
                        id: videoOutput
                        anchors.fill: parent
                        fillMode: VideoOutput.PreserveAspectFit

                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                if (mediaPlayer.playbackState === MediaPlayer.PlayingState)
                                    mediaPlayer.pause();
                                else
                                    mediaPlayer.play();
                            }
                        }
                    }
...
</code></pre>
<p dir="auto">In the C++ code, I check for OpenSSL:</p>
<pre><code>qDebug() &lt;&lt; "OpenSSL supported:" &lt;&lt; QSslSocket::supportsSsl();

qDebug() &lt;&lt; QSslSocket::supportsSsl() &lt;&lt; QSslSocket::sslLibraryBuildVersionString() &lt;&lt;" , "&lt;&lt; QSslSocket::sslLibraryVersionString();

qDebug() &lt;&lt; manager-&gt;supportedSchemes();

</code></pre>
<p dir="auto">In the application output window, I see:<br />
<strong>D/default (14712): OpenSSL supported: true<br />
D/default (14712): true "OpenSSL 3.0.7 1 Nov 2022", "OpenSSL 3.1.8 11 Feb 2025"<br />
D/default (14712): QList("file", "qrc", "assets", "http", "unix+http", "local+http", "https", "data")</strong><br />
.<br />
However, if I use WebView instead of MediaPlayer, like this:</p>
<pre><code>...
                WebView {
                    id: webview
                    ...
                    url: "https://cdn.some_domen/.../stream.m3u8?uuid=some_uuid&amp;token=some_token"
                   ...
                }
...
</code></pre>
<p dir="auto">, then stream playback is working.<br />
The Qt version is 6.10.1.<br />
Has anyone come across this?<br />
Thanks in advance!</p>
]]></description><link>https://forum.qt.io/topic/164356/qt-6-qml-mediaplayer-not-playing-m3u8-streams-on-android-while-webview-does</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 21:27:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164356.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Mar 2026 18:49:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Fri, 06 Mar 2026 16:30:32 GMT]]></title><description><![CDATA[<p dir="auto">Interesting! I recently did some experimentation with Qt combined with IP camera, and I had less-than-ideal results (which I planned to revisit at some point but have not gotten around to).</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/woodpecker">@<bdi>woodpecker</bdi></a> How is the timing/lag/performance?</p>
<p dir="auto">My principal issue was huge lag, which I also experienced when just using ffmpeg at the command line. (Since Qt uses ffmpeg under the hood I suspect the actual source of lag is therefore ffmpeg.)</p>
<p dir="auto">I had come across:</p>
<p dir="auto"><a href="https://forum.qt.io/topic/79208/how-to-kill-delay-in-live-streaming">https://forum.qt.io/topic/79208/how-to-kill-delay-in-live-streaming</a> (which never got any reply at all)</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/7759695/terrible-performance-with-qmediaplayer-and-qvideowidget" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/7759695/terrible-performance-with-qmediaplayer-and-qvideowidget</a></p>
<p dir="auto">But your (very) recent outcome will be of interest to myself and others! How's the lag?</p>
<p dir="auto">(Also, you mentioned 6.10.1 but can you also state which OS or OSes?) <em><strong>EDIT: Android is in the title!</strong></em> But still I'm curious if you build for Linux/Windows also?</p>
]]></description><link>https://forum.qt.io/post/836900</link><guid isPermaLink="true">https://forum.qt.io/post/836900</guid><dc:creator><![CDATA[KH-219Design]]></dc:creator><pubDate>Fri, 06 Mar 2026 16:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Fri, 06 Mar 2026 08:59:25 GMT]]></title><description><![CDATA[<p dir="auto">QML</p>
<pre><code>                    VLCPlayer {
                        id: vlcplayer
                        videoSink: videoOutput.videoSink
                    }

                    VideoOutput {
                        id: videoOutput
                        anchors.fill: parent
                        fillMode: VideoOutput.PreserveAspectFit
                    }
                    
                    Component.onCompleted: vlcplayer.setSource("https://cdn.some_domen/.../stream.m3u8?uuid=some_uuid&amp;token=some_token")


</code></pre>
]]></description><link>https://forum.qt.io/post/836858</link><guid isPermaLink="true">https://forum.qt.io/post/836858</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Fri, 06 Mar 2026 08:59:25 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Fri, 06 Mar 2026 08:54:37 GMT]]></title><description><![CDATA[<p dir="auto">Because of the phrase "#include &lt;Q D e b u g&gt;," Askit considered this code spam.)<br />
However, QDebug still needs to be enabled.</p>
]]></description><link>https://forum.qt.io/post/836857</link><guid isPermaLink="true">https://forum.qt.io/post/836857</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Fri, 06 Mar 2026 08:54:37 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Fri, 06 Mar 2026 08:48:07 GMT]]></title><description><![CDATA[<pre><code>#include "vlcplayer.h"
#include &lt;QPainter&gt;
#include &lt;QVideoFrame&gt;

VLCPlayer::VLCPlayer() {
    videoBuffer.resize(VIDEO_WIDTH * VIDEO_HEIGHT * 4); // RGBA
    connect(this, &amp;VLCPlayer::frameReady, this, &amp;VLCPlayer::onframeReady);
}

void VLCPlayer::setSource(const QString &amp;path) {
    // const char* vlc_args[] = { "--no-osd" };
    _vlcInstance = libvlc_new(0, nullptr); //libvlc_new(1, vlc_args);
    _vlcPlayer = libvlc_media_player_new(_vlcInstance);

    // Set the format: RGBA (4 bytes per pixel), width, height, pitch
    libvlc_video_set_format(_vlcPlayer, "RGBA", VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH * 4);

    // Link our functions
    libvlc_video_set_callbacks(_vlcPlayer, &amp;VLCPlayer::lock, &amp;VLCPlayer::unlock, &amp;VLCPlayer::display, this);

    libvlc_media_t *m = libvlc_media_new_location(_vlcInstance, path.toUtf8().constData());
    libvlc_media_player_set_media(_vlcPlayer, m);
    libvlc_media_release(m);
    libvlc_media_player_play(_vlcPlayer);
}

QVideoSink* VLCPlayer::videoSink() const
{
    return m_videoSink.get();
}

void VLCPlayer::setVideoSink(QVideoSink *newVideoSink)
{
    if (m_videoSink == newVideoSink)
        return;
    m_videoSink = newVideoSink;
    emit videoSinkChanged();
}

void* VLCPlayer::lock(void *opaque, void **planes) {
    VLCPlayer *player = static_cast&lt;VLCPlayer*&gt;(opaque);
    player-&gt;bufferMutex.lock();
    *planes = player-&gt;videoBuffer.data();
    return nullptr;
}

void VLCPlayer::unlock(void *opaque, void *picture, void *const *planes) {
    VLCPlayer *player = static_cast&lt;VLCPlayer*&gt;(opaque);
    player-&gt;bufferMutex.unlock();
}

void VLCPlayer::display(void *opaque, void *picture) {
    VLCPlayer *player = static_cast&lt;VLCPlayer*&gt;(opaque);
    // Generate a signal to redraw the user interface in Qt's main thread
    emit player-&gt;frameReady();
}

void VLCPlayer::onframeReady()
{
    if(!m_videoSink)
        return;

    bufferMutex.lock();

    // Create a QImage object that simply "looks" at your video buffer (without copying)
    QImage img(videoBuffer.data(), VIDEO_WIDTH, VIDEO_HEIGHT, QImage::Format_RGBA8888);

    // In Qt 6, you can create a frame directly from a QImage
    // if the formats match, Qt will try to minimize overhead
    QVideoFrame frame(img);

    // Sending to Sink
    m_videoSink-&gt;setVideoFrame(frame);

    bufferMutex.unlock();
}

</code></pre>
]]></description><link>https://forum.qt.io/post/836855</link><guid isPermaLink="true">https://forum.qt.io/post/836855</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Fri, 06 Mar 2026 08:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Thu, 05 Mar 2026 11:28:41 GMT]]></title><description><![CDATA[<p dir="auto">I can't paste it - I get a message that it's spam...</p>
]]></description><link>https://forum.qt.io/post/836804</link><guid isPermaLink="true">https://forum.qt.io/post/836804</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Thu, 05 Mar 2026 11:28:41 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Thu, 05 Mar 2026 11:19:42 GMT]]></title><description><![CDATA[<p dir="auto">vlcplayer.cpp</p>
]]></description><link>https://forum.qt.io/post/836803</link><guid isPermaLink="true">https://forum.qt.io/post/836803</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Thu, 05 Mar 2026 11:19:42 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Thu, 05 Mar 2026 11:02:08 GMT]]></title><description><![CDATA[<p dir="auto">vlcplayer.h</p>
<pre><code>#ifndef VLCPLAYER_H
#define VLCPLAYER_H

#include &lt;vlc/vlc.h&gt;
#include "vlc/libvlc_media.h"
#include "vlc/libvlc_media_player.h"
#include &lt;QtQml/qqmlregistration.h&gt; //for QML_ELEMENT
#include &lt;QMutex&gt;
#include &lt;vector&gt;
#include &lt;QPointer&gt;
#include &lt;QVideoSink&gt;

// using namespace QNativeInterface;

// extern "C" {
// // We declare the function we found using nm
// void libvlc_media_player_set_android_context(libvlc_media_player_t *p_mi, void *p_jvm_or_surface);
// }

class VLCPlayer : public QObject {
    Q_OBJECT
    QML_ELEMENT // This makes the class available for use/instantiation on the QML side.
    Q_PROPERTY(QVideoSink* videoSink READ videoSink WRITE setVideoSink NOTIFY videoSinkChanged)
public:
    VLCPlayer();

    Q_INVOKABLE void setSource(const QString &amp;path);

   // 1. LOCK: VLC asks where to write the pixels of the next frame
   static void* lock(void *opaque, void **planes);

   // 2. UNLOCK: The frame has been written to the buffer
   static void unlock(void *opaque, void *picture, void *const *planes);

   // 3. DISPLAY: It's time to tell Qt that the image has been updated
   static void display(void *opaque, void *picture);

   QVideoSink *videoSink() const;
   void setVideoSink(QVideoSink *newVideoSink);

    // Video settings (can be changed)
    const int VIDEO_WIDTH = 1280;
    const int VIDEO_HEIGHT = 720;

    std::vector&lt;uchar&gt; videoBuffer;
    QMutex bufferMutex;
    libvlc_media_player_t *mp = nullptr;
signals:
    void videoSinkChanged();
    void frameReady();

public slots:
    void onframeReady();

private:
    libvlc_instance_t *_vlcInstance;
    libvlc_media_player_t *_vlcPlayer;
    QPointer&lt;QVideoSink&gt; m_videoSink;
};</code></pre>
]]></description><link>https://forum.qt.io/post/836801</link><guid isPermaLink="true">https://forum.qt.io/post/836801</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Thu, 05 Mar 2026 11:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Thu, 05 Mar 2026 11:00:43 GMT]]></title><description><![CDATA[<p dir="auto">If anyone is interested, here is the code:<br />
main.cpp</p>
<pre><code>#include &lt;QGuiApplication&gt;
#include &lt;QQmlApplicationEngine&gt;

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // 1. Load dependencies in the correct order via the Java layer
    // This will automatically call JNI_OnLoad and install s_jvm in VLC
    QJniObject::callStaticMethod&lt;void&gt;(
        "java/lang/System",
        "loadLibrary",
        "(Ljava/lang/String;)V",
        QJniObject::fromString("vlc").object() // core first
        );

    QQmlApplicationEngine engine;
    QObject::connect(
        &amp;engine,
        &amp;QQmlApplicationEngine::objectCreationFailed,
        &amp;app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);
    engine.loadFromModule("myproject", "Main");

    return app.exec();
}

</code></pre>
<p dir="auto">.</p>
]]></description><link>https://forum.qt.io/post/836800</link><guid isPermaLink="true">https://forum.qt.io/post/836800</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Thu, 05 Mar 2026 11:00:43 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Thu, 05 Mar 2026 10:58:24 GMT]]></title><description><![CDATA[<p dir="auto">After a long conversation with the AI, I managed to get playback working using the libvlc library!</p>
]]></description><link>https://forum.qt.io/post/836799</link><guid isPermaLink="true">https://forum.qt.io/post/836799</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Thu, 05 Mar 2026 10:58:24 GMT</pubDate></item><item><title><![CDATA[Reply to Qt 6 QML MediaPlayer not playing M3U8 streams on Android, while WebView does on Wed, 04 Mar 2026 12:40:22 GMT]]></title><description><![CDATA[<p dir="auto">I tried using the libvlc library, c++:</p>
<pre><code>#include &lt;vlc/vlc.h&gt;
#include "vlc/libvlc_media.h"
#include "vlc/libvlc_media_player.h"
#include &lt;QQuickItem&gt;

class VLCPlayer : public QQuickItem {
    Q_OBJECT
    QML_ELEMENT // This makes the class available for use/instantiation on the QML side.
    Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)

public:
    VLCPlayer() {
        qDebug() &lt;&lt; "libvlc_new(0, nullptr)...";

        _vlcInstance = libvlc_new(0, nullptr);

        qDebug() &lt;&lt; "libvlc_media_player_new...";

        _vlcPlayer = libvlc_media_player_new(_vlcInstance);
    }

    void setSource(const QString &amp;path) {
        libvlc_media_t *m = libvlc_media_new_path(_vlcInstance, path.toUtf8().data());
        libvlc_media_player_set_media(_vlcPlayer, m);
        libvlc_media_release(m);
        libvlc_media_player_play(_vlcPlayer);
        emit sourceChanged();
    }

    QString source() const
    {
        return "";
    }

signals:
    void sourceChanged();

private:
    libvlc_instance_t *_vlcInstance;
    libvlc_media_player_t *_vlcPlayer;
};
</code></pre>
<p dir="auto">and QML:</p>
<pre><code>                    VLCPlayer {
                        id: player
                        anchors.fill: parent
                        source: "https://cdn.some_domen/.../stream.m3u8?uuid=some_uuid&amp;token=some_token"
                    }

</code></pre>
<p dir="auto">,<br />
but in the constructor, on the line<br />
<strong>_vlcInstance = libvlc_new(0, nullptr);</strong><br />
the program crashes with the error:<br />
<strong>Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 10680 (qtMainLoopThrea)...</strong> .</p>
]]></description><link>https://forum.qt.io/post/836765</link><guid isPermaLink="true">https://forum.qt.io/post/836765</guid><dc:creator><![CDATA[woodpecker]]></dc:creator><pubDate>Wed, 04 Mar 2026 12:40:22 GMT</pubDate></item></channel></rss>