RTSP streaming desktop and Android device delay test in FFmpeg

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

insert image description here
insert image description here

● GitHub

Releases · BtbN/FFmpeg-Builds (github.com)
insert image description here

● CSDN has uploaded ffmpeg and rtsp servers:

‍FFmpeg RTSP streaming desktop

1.2 RTSP streaming server

● GitHub

Releases · aler9/mediamtx (github.com)

insert image description here

2. Execution process

​ After decompression:

insert image description here

2.1 Start the server

● ​Double-click to run:

insert image description here

● ​This interface pops up:

insert image description here

2.2 Execute desktop streaming

● Open the terminal under the source bin file:

insert image description here

● 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 :

insert image description here

● Open to open Beijing time:

Beijing time calibration_Beijing time online calibration display milliseconds - countdown timer (daojishiqi.com)

2.3 play

● vlc playback stream:

rtsp://127.0.0.1:8554/stream

insert image description here

● Display:

It can be seen that the delay of vlc is quite large:

insert image description here

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/streamaddress

安卓采用 FFMPEG 4.4.1版本,使用 QVideoFrame 代替sws方案,VideoOutput 来刷新图片

insert image description here
insert image description here
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 为格式化输出到哪里
    

Guess you like

Origin blog.csdn.net/qq_16504163/article/details/130240684