Article directory
1. FFMPEG streaming:
1.1 FFmpeg source code preparation
Just choose one of the official website, GitHub, and CSDN:
● Official website:
Builds - CODEX FFMPEG @ gyan.dev
Download source code: just choose one
● GitHub:
Releases · BtbN/FFmpeg-Builds (github.com)
● CSDN has uploaded ffmpeg and rtsp servers:
FFmpeg RTSP streaming desktop
1.2 RTSP streaming server
● GitHub:
Releases · aler9/mediamtx (github.com)
2. Execution process
After decompression:
2.1 Start the server
● Double-click to run:
● This interface pops up:
2.2 Execute desktop streaming
● Open the terminal under the source bin file:
● Run command:
ffmpeg -f gdigrab -i desktop -s 1280x720 -rtsp_transport tcp -preset ultrafast -acodec libfaac -f rtsp rtsp://127.0.0.1:8554/stream
Parameter Description:
,-f gdigrab
gdigrab is a screen capture device based on Win32 GDI. Can capture the screen image of the display area of the Windows desktop screen
:-i desktop
Specify the input file. desktop means that the input device is a desktop screen
:-f rtsp rtsp://127.0.0.1:8554/stream
The output format is rtsp stream, and the address is the local machine address
● Start streaming :
● Open to open Beijing time:
2.3 play
● vlc playback stream:
rtsp://127.0.0.1:8554/stream
● Display:
It can be seen that the delay of vlc is quite large:
3. Android testing
● ipconfig finds that the address of the Windows machine is 192.168.xx.xx
● Android player input rtsp://192.168.xx.xx/stream
address
安卓采用 FFMPEG 4.4.1版本,使用 QVideoFrame 代替sws方案,VideoOutput 来刷新图片
In addition to image transmission and re-testing, the delay will be increased by about 50~100ms
● Other ways to push streams :
-
The desktop push stream introduced in this article:
ffmpeg -f gdigrab -i desktop -s 1280x720 -rtsp_transport tcp -preset ultrafast -acodec libfaac -f rtsp rtsp://127.0.0.1:8554/stream
-
UDP streaming:
ffmpeg -re -i input.mp4 -c copy -f rtsp rtsp://127.0.0.1:8554/stream
-
TCP streaming:
ffmpeg -re -i input.mp4 -c copy -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:8554/stream
-
Circular push flow:
ffmpeg -re -stream_loop -1 -i input.mp4 -c copy -f rtsp rtsp://127.0.0.1:8554/stream
其中: -re 为以流的方式读取; -stream_loop 为循环读取视频源的次数,-1为无限循环; -i 为输入的文件; -f 为格式化输出到哪里