Streaming and showing video using a QVideoWidget object + FFmpeg
-
wrote on 4 May 2023, 20:30 last edited by
Hello,
I'm using QT 6.5 to receive and stream a video, using UDP. This version of QT uses Ffmpeg as default multimedia backend, so I started using QProcess to connect with the server and the 'ffplay' command to present the image. However, I need to embed the video in my application, not just open another screen. Similar to setting my output to a QVideoWidget.
I already tried some options, like setting like this
QMediaPlayer* player->setSource(QUrl("udp://127.0.0.1:5000")); mediaPlayer->setVideoOutput(ui->widget_Video);
but the screen is still black.
Does anyone know how to do that or have any suggestions? -
Hello,
I'm using QT 6.5 to receive and stream a video, using UDP. This version of QT uses Ffmpeg as default multimedia backend, so I started using QProcess to connect with the server and the 'ffplay' command to present the image. However, I need to embed the video in my application, not just open another screen. Similar to setting my output to a QVideoWidget.
I already tried some options, like setting like this
QMediaPlayer* player->setSource(QUrl("udp://127.0.0.1:5000")); mediaPlayer->setVideoOutput(ui->widget_Video);
but the screen is still black.
Does anyone know how to do that or have any suggestions? -
@Ximenes "udp://127.0.0.1:5000" does not seem to be a correct URL to me for streaming. The ip address of the streaming source(camera) on your server is needed here.
wrote on 5 May 2023, 13:21 last edited byYes, I think the URL pass is incorrect anyway. But to clarify, my project connects to a device via access point and when starting the UDP connection, it starts to receive image data. For the codec, I'm using FFmpeg. As a rule, I can capture and display the images and/or save to a file using ffplay or ffmpeg, for example. However, what I would like to do is display the incoming footage in a QT object such as the QVideoWidget. I hope I have clarified the objective.
In other versions of QT it was possible to add media with player.addMedia(QUrl("udp://XXX.X.X:YYYY")); but that option has been removed in the latest versions :(
So anyone have any suggestions how to do it?
-
Yes, I think the URL pass is incorrect anyway. But to clarify, my project connects to a device via access point and when starting the UDP connection, it starts to receive image data. For the codec, I'm using FFmpeg. As a rule, I can capture and display the images and/or save to a file using ffplay or ffmpeg, for example. However, what I would like to do is display the incoming footage in a QT object such as the QVideoWidget. I hope I have clarified the objective.
In other versions of QT it was possible to add media with player.addMedia(QUrl("udp://XXX.X.X:YYYY")); but that option has been removed in the latest versions :(
So anyone have any suggestions how to do it?
-
@Ximenes I am not using Qt6 for streaming. It is better to go through the latest examples of Qt6 multimedia to find that out. Maybe someone else can help you out.
Lifetime Qt Championwrote on 5 May 2023, 19:16 last edited by SGaist 5 May 2023, 19:16Hi,
You are likely hitting QTBUG-111910.
-
-
wrote on 5 Jun 2023, 16:31 last edited by Ximenes 6 May 2023, 16:31
Hello,
I have some good news, the last version from QT 6.5.1 solved this issue.
Now we can stream using some protocol, like UDP or TCP, directly to a widget from QT, used as output.mediaPlayer->setVideoOutput(ui->widget_Video); QMediaPlayer* player->setSource(QUrl("udp://XXX.X.X.X:YYYY));
-
-
Hello,
I have some good news, the last version from QT 6.5.1 solved this issue.
Now we can stream using some protocol, like UDP or TCP, directly to a widget from QT, used as output.mediaPlayer->setVideoOutput(ui->widget_Video); QMediaPlayer* player->setSource(QUrl("udp://XXX.X.X.X:YYYY));
1/7