Qt streaming program (video file/video stream/camera/desktop converted to streaming media rtmp+hls+webrtc) can be viewed remotely on web pages and players

1. Introduction

Push streaming is the process of transmitting the packaged content in the collection stage to the server. In fact, it is the process of packing and transmitting the live video signal from the mobile phone, computer, and camera to the server. "Push streaming" has relatively high requirements on the network. If the network is unstable, the live broadcast effect will be poor, and the audience will experience freezes when watching the live broadcast, and the viewing experience will be poor. The mainstream push protocols include RTMP, HLS, SRT, etc. RTMP is currently the most mainstream streaming media transmission protocol. It supports CDN well and is less difficult to implement. It is the choice of most live broadcast platforms. The delay of RTMP transmission is usually 1–3 seconds, which is suitable for mobile phones. However, RTMP does not support browsers. If the live broadcast service requires a browser, additional push protocol support is required. HLS is an HTTP-based streaming media real-time transmission protocol defined by Apple. HLS realizes the experience of live broadcast with on-demand technology. Because the duration of each small file is very short, the client can quickly switch the bit rate to adapt to playback under different bandwidth conditions. However, the latency of HLS is generally higher than that of ordinary live streaming protocols. RTC is an open source protocol that supports browsers for real-time voice and video conversations. RTC supports the current mainstream browsers, and has good stability even when the network signal is normal. It can realize point-to-point communication, and the delay between the communication parties is low. It is a better choice to realize the "connected microphone" function.

Pull streaming is to rebroadcast videos from other platforms. It is the process of pulling the existing live content from the server with the specified address. The client sends an access request to the server for the streaming address of the video file, then accesses the on-demand platform to distribute the live video stream, and then receives the distributed video data, so as to achieve the effect of watching the rebroadcast video on the third-party platform. Push and pull streams basically use ffmpeg, and ffmpeg code can be used to implement push and pull stream playback, but streaming media servers generally choose third-party component wheels, such as mediamtx, srs, EasyDarwin, LiveQing, ZLMediaKit, etc. Personal preference is to use mediamtx, single-file publishing, and satisfying functions. Go writing is inherently high-concurrency, open source and free.

2. Features

2.1 File push

  1. Specify the network card and listening port, and receive network requests to push various files such as audio and video.
  2. Real-time statistics display the number of visits corresponding to each file, the total number of visits, and the number of visits from different IP addresses.
  3. Multiple modes can be specified, 0-direct play, 1-download play.
  4. Real-time printing displays various sending and receiving request and response data.
  5. Each file corresponds to an MD5-encrypted unique identifier, which is used to request the address suffix to distinguish which file to access.
  6. Support various browsers (Google chromium/Microsoft edge/Firefox firefox, etc.), various players (vlc/mpv/ffplay/potplayer/mpchc, etc.) to open requests.
  7. During the playback process, the playback progress can be switched arbitrarily, and double-speed playback is supported.
  8. The name history of the file that needs to be streamed is automatically stored and opened to load the application.
  9. Switch files to get the access address, and automatically copy the address to the clipboard for direct pasting and testing.
  10. Extremely low CPU usage, 128-channel 1080P simultaneous streaming is less than 1% CPU usage, asynchronous data sending mechanism.
  11. Pure QTcpSocket communication, does not depend on the streaming media service program, the core source code is less than 500 lines, with detailed annotations and complete functions.
  12. Support any version of Qt4/Qt5/Qt6, support any system (windows/linux/macos/android/embedded linux, etc.).

2.2 Network streaming

  1. Support various local video files and network video files.
  2. Support various network video streams, webcams, protocols including rtsp, rtmp, http.
  3. It supports streaming of local camera devices, and the resolution and frame rate can be specified.
  4. Supports streaming of local desktops, specifying screen area and frame rate, etc.
  5. Automatically start the streaming media service program, the default mediamtx (formerly rtsp-simple-server), you can choose srs, EasyDarwin, LiveQing, ZLMediaKit, etc.
  6. You can switch and preview video files in real time.
  7. The clarity and quality of streaming can be adjusted.
  8. Files, directories and addresses can be added dynamically.
  9. Video files are automatically streamed in a loop. If the video source is a video stream, it will automatically reconnect after being disconnected.
  10. The network video stream is automatically reconnected, and the reconnection is successful and the streaming will continue automatically.
  11. The real-time performance of network video streaming is extremely high, and the delay is extremely low. The delay time is about 100ms.
  12. Extremely low CPU usage, 4 channels of main stream streaming only need to occupy 0.2% of CPU. Theoretically, there is no pressure to push 100 channels on conventional ordinary PC machines, and the main performance bottleneck lies in the network.
  13. After pushing the stream, in addition to using the rtmp address to access, it also supports direct hls/webrtc access, and you can directly open the browser to view the real-time screen.
  14. You can push the stream to the external network server, and then play the corresponding video stream through mobile phones, computers, tablets and other devices.
  15. Support any version of Qt4/Qt5/Qt6, support any system (windows/linux/macos/android/embedded linux, etc.).

3. Experience address

  1. Experience address: https://pan.baidu.com/s/1d7TH_GEYl5nOecuNlWJJ7g Extraction code: 01jf Name: bin_video_push
  2. Domestic site: https://gitee.com/feiyangqingyun
  3. International site: https://github.com/feiyangqingyun
  4. Personal homepage: https://blog.csdn.net/feiyangqingyun
  5. Zhihu homepage: https://www.zhihu.com/people/feiyangqingyun/

4. Use steps

4.1 File streaming

  1. Select or fill in the IP address of the network card to be monitored, fill in the listening port, and it is recommended to default.
  2. Click Add File or Directory, select the audio and video files to be added to the push stream, and they will be automatically listed in the table after the addition is successful.
  3. Click the start service button, it will change to stop service, indicating that the service is started successfully.
  4. Select a line from the table, the playback address of the audio and video file will be automatically filled in the lower right corner, and it will also be automatically copied to the clipboard.
  5. Paste the address into the address bar of the browser and press Enter to view the playback audio and video, and you can switch the playback progress arbitrarily.
  6. Open the address with vlc or other players to view the playback audio and video, and you can switch the playback progress arbitrarily.
  7. The file streaming service supports multiple simultaneous requests, and the table will display the number of requests being made for each file, and the bottom right corner also counts the total number of requests, as well as the total number of requests from different IP addresses.
  8. Clicking the stop service button will stop all services. Due to the existence of the cache, the video in the cache can continue to play after stopping, but it will not be played after a period of time.
  9. Supports dynamically adding files, removing files, and clearing files after starting the service.

4.2 Network streaming

  1. Select or fill in the prefix address of the push stream, it is recommended to default.
  2. Click Add File or Directory, select the audio and video files to be added to the push stream, and they will be automatically listed in the table after the addition is successful.
  3. Click Add Address, you can select or fill in from the drop-down box, the drop-down options are some format templates, such as local camera, local desktop, TV station, network camera, etc.
  4. Click the start service button, it will change to stop service, indicating that the service is started successfully.
  5. After starting the service, it supports dynamically adding addresses, removing addresses, and clearing addresses. If it is in the startup service, it will push the stream immediately after adding it.
  6. Select a line from the table, the playback address will be automatically filled in the lower right corner, and it will also be automatically copied to the clipboard.
  7. A push stream can be accessed by different addresses. There are three addresses in the lower right corner. The first is the address of the video stream starting with rtmp, which can be opened by various players. The second is the address in hls (m3u8) format. It is generally used for web browser display, and the third type is the address in webrtc format, which is generally used in browsers or players that partially support this format.
  8. Paste the address into the address bar of the browser and press Enter to view the video stream, and the address can also be opened with a player.
  9. Clicking the stop service button will stop all services, and support dynamically adding files, removing files, and clearing files after starting services.

Five, renderings

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/feiyangqingyun/article/details/130656915