RK3568 Development Notes (11): The development version of the buildroot firmware transplants a ffmpeg rtsp player demo

If the article is an original article, please indicate the source of the original article when reprinting it.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/133022813

Red Fatty Internet Technology Blog Collection: Development technology collection (including Qt practical technology, Raspberry Pi, 3D, OpenCV, OpenGL, ffmpeg, OSG, microcontroller, software and hardware combination, etc.) is being continuously updated...

Rockchip Development Column

Previous article: " RK3568 Development Notes (10): Application Demo developed by transplanting the development board buildroot firmware, starting full-screen display "
Next article: Stay tuned...


Preface

  The target development task also has a function, which is to play rtsp cameras. Of course, in order to better sit on this, we must support retrying after rtsp playback fails, such as retrying to open it once every 5 seconds, so as to ensure that it can be reopened after being connected to the Internet, and then achieve this function. .


Demo

  Please add image description


Replenish

  Thanks to the buildroot on the solution, ffmpeg4.1.3 has been ported.
  Insert image description here


Camera hardware connection

  Insert image description here


Compile ffmpeg4.1.3

  Insert image description here

  During the program transplantation process, it was found that the default ffmpge was missing swscale.h , which was very difficult to handle:
  Insert image description here

  I thought of a way to patch it, cross-compile ffmpeg4.1.3 and patch it again.

Step 1: Download and unzip

  http://ffmpeg.org/releases/Unzip
  Insert image description here
  :
  Insert image description here

Step 2: Configure configure

  Introduce cross compiler
  Insert image description here

export PATH=$PATH:/home/yang/work/src/topeet-qt5.14.2/topeet-qt5.14.2-aarch64/host/bin

  Adjust the configuration as follows:

./configure --prefix=/home/yang/work/src/topeet-qt5.14.2/topeet-qt5.14.2-aarch64/host/aarch64-buildroot-linux-gnu/sysroot --arch=aarch64  --target-os=linux  --enable-cross-compile --cross-prefix=aarch64-buildroot-linux-gnu- --enable-shared

  Insert image description here

Step 3: Compile make

make -j4

  Insert image description here

Step 4: Install make install

make install

   Insert image description here

Step 5: Check the libswsale image scaling and transformation module:

  Insert image description here

  But the compilation still doesn’t work:
  Insert image description here

  I couldn't bear it anymore, so I re-extracted a complete set of dependencies directly for the Qt project:
  note that the prefix address was modified:

./configure --prefix=/home/yang/work/src/ffmpeg-aarch64 --arch=aarch64  --target-os=linux  --enable-cross-compile --cross-prefix=aarch64-buildroot-linux-gnu- --enable-shared

  Go through it again and get it into the ffmpeg code alone:
  Insert image description here

  Get it in the code module:
  Insert image description here

  Add pri dependency:
  Insert image description here

  Compile, this time no header file error occurred, but a new error occurred:
  Insert image description here

  Insert image description here

  Compile and pass:
  Insert image description here

  Compilation dependencies are resolved:
  Insert image description here

Step 6: Cover ffmpeg4.1.2 on the development board with ffmpeg

  You have to overwrite the new library, otherwise the following will appear:
  Insert image description here

  Because sftp restricts the /root directory, package it directly and manually copy and overwrite it on the development board:
  Insert image description here

  Copy to development board:
  Insert image description here

  In fact, there is no need for a header file here. If the target board does not compile, there is no need for a header file. Just decompress the lib directly, and then copy everything in the folder to /usr/lib, as shown below:
  Insert image description here

  Then run:
  Insert image description here

  Successfully, look at the interface:
  Insert image description here


Start testing soft decoding rtsp

Ffmpeg pulls rtsp software to decode h364 display (1080p)

  Then start soft decoding rtsp playback:
  Insert image description here

  Playing for 1 second increases by 1 second, getting slower and slower, then turns gray and starts again:
  Insert image description here

  Check the CPU, decoding 1080p directly explodes the CPU:
  Insert image description here

  This approach won't work.

Ffmpeg pulls rtsp software to decode h364 and displays 360p (640x360)

  Switch to substream:
  Insert image description here

  The delay is about 1s-1.5s
  Insert image description here

  as follows:
  Insert image description here

  Then I tested and opened two decoders, and the delay basically had no effect. Then I ran the application to decode and interact with data for 50ms. There were no problems, so I can just demonstrate this first.


summary

  The goal has been basically achieved this time. At the same time, it has been measured that rk can use mpp to pull rtsp and decode h264 packets into rgba. Directly brushing the buffer layer is the lowest delay and the lowest cpu consumption. It can also be displayed to qt, which consumes a little more delay. , it should be 10~30ms longer. The actual result needs to be tested.


Previous article: " RK3568 Development Notes (10): Application Demo developed by transplanting the development board buildroot firmware, starting full-screen display "
Next article: Stay tuned...


If the article is an original article, please indicate the source of the original article when reprinting it.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/133022813

Guess you like

Origin blog.csdn.net/qq21497936/article/details/133022813