0

I'm needing to display RTSP footage through a QML application. I have code written for this that works perfectly on Linux, simply because QT ships with a gstreamer backend on linux straight out of the box. On Windows this is a different story. Windows comes with "Windows Media Foundation" which doesn't support hardly any formats/codecs, much less an rtsp stream.

QT says with the release of QT6.4 they added an FFMPEG backend as a preview(https://doc-snapshots.qt.io/qt6-6.4/qtmultimedia-index.html). Some people on articles claim theyve gotten a working version by compiling QT with ffmpeg(https://forum.qt.io/topic/140524/use-ffmpeg-with-qt6-4/16). Everyone fails to produce steps and detailed information. I'm needing some help getting my QT6.4 installation to work with a ffmpeg backend. Also I've tried it with the mentioned environment variable as well.

If we can solve this here, we would be benefiting TONS of people. I can't tell you how many people have been posting about this.

Here's the quote from QT:

"Target platform and backend notes On most platforms, there are two different backends that can be used for Qt Multimedia.

The first one is the backend built on the native multimedia framework of the underlying >operating system. This is currently the default, and will use gstreamer on Linux, >AVFoundation on macOS/iOS, WMF on Windows, and the MediaCodec framework on Android.

While we try to support our full API on all backends using the native multimedia framework, >platform specific limitations do exist in a few places. This is due to the fact that the >feature set supported by those frameworks varies, implying that some functionality might >not be available on all platforms. This is especially true for the set of supported file >formats and codecs, as well as advanced camera functionality.

Where limitations exist, we aim to document those in the respective classes and methods.

With Qt 6.4, we are adding a new, more platform independent backend based on the FFmpeg >framework. The FFmpeg backend is currently available as a technology preview. This backend >has the advantage that we can offer proper cross-platform support for all features of Qt >Multimedia, going beyond the limitations that exist with many of the native frameworks.

You can test the FFmpeg backend right now by using a Qt build that has FFmpeg enabled and >setting the QT_MEDIA_BACKEND environment variable to ffmpeg:

export QT_MEDIA_BACKEND=ffmpeg"

And here's my WORKING code on Linux:

import QtQuick
import QtMultimedia
import QtQml
Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
    color: "#000000"
    Video {
            id: stream
            anchors.fill: parent
            focus: true
            source: "MY URL"
            opacity: 1.0
            fillMode: Image.Stretch
            muted: true
            Timer {
                    interval: 300000; running: true; repeat: true
                    onTriggered: {
                        console.log("Log: Refresh")
                        stream.stop()
                        stream.source="MY URL"
                        stream.play()
                    }
                }
            onErrorChanged: {
                console.log("VIDEO ERROR")
                stream.stop()
                stream.source="MY URL"
                stream.play()
            }

            Text {
                id: text1
                width: 73
                height: 18
                color: "#ffffff"
                text: qsTr("Audio: False")
                anchors.left: parent.left
                anchors.top: parent.top
                font.pixelSize: 15
                anchors.leftMargin: 0
                anchors.topMargin: 0
            }

            Keys.onPressed: (event)=> {
                if(event.key === Qt.Key_M) {
                                    stream.play()
                    if(text1.text === "Audio: True") {
                        text1.text = "Audio: False"
                        stream.muted = true
                    } else if (text1.text === "Audio: False") {
                        text1.text = "Audio: True"
                        stream.muted = false
                    }
                }
            }
    }
//    Component.onCompleted: {
//        stream.play()
//    }
}
sethsource
  • 185
  • 9

1 Answers1

1

Qt introduced the ffmpeg backend in 6.4; in 6.4 the ffmpeg backend is available in most binary builds, but it should be switched on by setting the environment variable QT_MEDIA_BACKEND=ffmpeg.

So in your case set it from the console or in main.cpp before qt initialization, e.g. setenv("QT_MEDIA_BACKEND", "ffmpeg")

Note, in 6.5, from beta 2, qt makes the ffmpeg backend default, native backends are optionally available. Aslo, in 6.5 the ffmpeg backend becomes more stable, so it's better to use it if possible.

If you want to compile qt with ffmpeg by yourself, you should install or compile ffmpeg by yourself. E.g., t makes sense to use qt provisioning build scripts: coin/provisioning/%os%/90-install-ffmpeg.sh After that ffmpeg path should be provided to qt's configuration: configure -submodules qtmultimedia -- -DFFMPEG_DIR=%ffmpegpath%

Config result is expected to contain: FFmpeg ............................... yes

  • Thank you for writing me. I've installed QT 6.5 and it gets me closer to a solution. when i run my program it outputs " Available HW decoding frameworks: dxva2 d3d11va " seems like it wants me to specify decoding frameworks, but i couldnt find any information online on how i'd go about doing this. – sethsource Jan 17 '23 at 16:31
  • I read on an ffmpeg forum that people make the use of dxva2 and d3d11va through a command line argument for video... "ffmpeg -hwaccel dxva2 -threads 1 -i INPUT -f null - -benchmark" but this is completely unrelated to QT. I attempted to use an envar for hwaccel and using command line arg and no difference. – sethsource Jan 17 '23 at 16:43
  • You see just some debug info. Currently, Qt uses D3D11VA on Windows if possible. In the current revision you may change it to dxva2 only by modifying and recompiling Qt by yourself if the change is really needed for some of your purposes, qtmultimedia/src/plugins/multimedia/ffmpeg/qffmpeghwaccel.cpp:37 – Artem Dyomin Jan 18 '23 at 16:45
  • Well my purpose is to display an RTSP feed. it's stil not working. I've found articles online of people getting this to work with new FFMPEG preview but they dont explain how and they dont check their DM's. – sethsource Jan 20 '23 at 15:05
  • Also, i'm still on beta 1 which is making me put the envar. How do i get access to beta 2? the online installer doesn't provide it – sethsource Jan 20 '23 at 15:19
  • Great pointer to Coin script, that is very convenient indeed. Unfortunately, even after I've built FFmpeg libraries and provided `-- -DFFMPEG_DIR="/usr/local/FFmpeg-n6.0"` to `configure`, it still doesn't discover FFmpeg: `FFmpeg ............................... no` (*and also prints `WARNING: No backend for low level audio found`, not sure if that's related*). That is with Qt 6.5.1 sources on Ubuntu 22.04. – retif May 27 '23 at 11:26