Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. UDP Video Streaming into QMediaPlayer (Qt6.6)
Qt 6.11 is out! See what's new in the release blog

UDP Video Streaming into QMediaPlayer (Qt6.6)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.3k Views 1 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.
  • I Offline
    I Offline
    iamontherun
    wrote on last edited by iamontherun
    #1

    I am trying to stream video feed into QMediaPlayer and I am having a hard time.

    Specs
    QT 6.6
    PySide6 (6.6.0)

    OS Tried
    Ubuntu 22.04.3 LTS (running on arm64 - macOS (m1 MacBook Pro)- vmware fusion)
    MacOs Ventura (m1 MacBook pro)

    I am using the following code,

    from PySide6.QtMultimedia import QMediaPlayer
    from PySide6.QtCore import QUrl, QTimer
    from PySide6.QtMultimediaWidgets import QVideoWidget
    from PySide6.QtWidgets import QWidget, QPushButton, QVBoxLayout
    
    
    class VideoViewer(QWidget):
        def __init__(self):
            super(VideoViewer, self).__init__()
            
            self.vid_layout = QVBoxLayout()
            self._get_video_btn = QPushButton("Get Video")
            self._get_video_btn.clicked.connect(self.play_video)
            
            self._player = QMediaPlayer()
            self._video_widget = QVideoWidget()
            self._player.setVideoOutput(self._video_widget)
    
            self.vid_layout.addWidget(self._get_video_btn)
            self.vid_layout.addWidget(self._video_widget)
    
            self.setLayout(self.vid_layout)
    
        def play_video(self):
            udp_source_url = "udp://127.0.0.1:1234/?udpsrc.caps=application/x-rtp,media=video,clock-rate=90000,encoding=H264,payload=26"  # Replace with your actual UDP source URL
            media_content = QUrl(udp_source_url)
            self._player.setSource(media_content)
            # Play the video
            self._player.play()
    

    Testing Stream

    gst-launch-1.0 videotestsrc pattern=ball ! video/x-raw,width=640,height=480 ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5600 code_text

    or simply to view webcam as a udp stream (
    gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoconvert ! video/x-raw,format=I420 ! x264enc tune=zerolatency ! rtph264pay ! udpsink host=127.0.0.1 port=5600 )

    I can view it fine using another gstreamer pipeline.

    gst-launch-1.0 udpsrc port=5600 ! application/x-rtp ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

    I also tried switching backends.

    os.environ['QT_MEDIA_BACKEND'] = 'gstreamer' or 'ffmpeg'
    os.environ['QT_DEFAULT_MEDIA_BACKEND'] = 'gstreamer' or 'ffmpeg'
    

    I went through all the forum past q&a and have no luck. Has anyone managed to stream udp using Qmediaplayer? If so please let me know. Highly appreciated!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you trying to use a custom GStreamer pipeline ? If so, it won't work with PySide6. The multimedia module has seen a big rewrite that removed that feature.

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

      I 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Are you trying to use a custom GStreamer pipeline ? If so, it won't work with PySide6. The multimedia module has seen a big rewrite that removed that feature.

        I Offline
        I Offline
        iamontherun
        wrote on last edited by
        #3

        @SGaist What are the standard UDP specs that QMediaPlayer Can read?

        at the moment I am trying to view this,

        gst-launch-1.0 videotestsrc pattern=ball ! video/x-raw,width=640,height=480 ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5600 code_text

        as a test stream. Final goal is to use a viewpro camera udp output.

        I tried to find the formats that can stream via QMediaPlayer and didn't find much.

        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