JeffyCN / FFmpeg

FFmpeg with rkmpp hwdec - (deprecated due to license issue, check gstreamer instead or https://github.com/nyanmisaka/ffmpeg-rockchip)
https://ffmpeg.org
Other
60 stars 18 forks source link

在请求地址是 rtsp 时不能工作 ... #3

Closed nulijiabei closed 2 years ago

nulijiabei commented 2 years ago

想从摄像头RTSP读取H264视频流,然后 RGA 转码成 YUV420P 但是 FFmpeg 在读取本地视频文件时是工作的,当读取 RTSP 时就不再进行解码,没有看到什么报错信息

JeffyCN commented 2 years ago

sorry, i can only handle issues related to rkmppdec, so please try to use ffmpeg's software decoder firstly(by disabling rkmppdec) to make sure it's an rkmppdec issue.

nulijiabei commented 2 years ago
Tinker Board 2S
root@linaro-alip:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
root@linaro-alip:~# 
git clone https://github.com/JeffyCN/FFmpeg.git -b 4.4
./configure --prefix=/usr/local --enable-version3 --disable-static --enable-shared \ 
            --enable-libdrm --enable-rkmpp --enable-librga
git clone https://github.com/rockchip-linux/mpp.git
root@linaro-alip:~# ldd /usr/local/bin/ffmpeg 
    linux-vdso.so.1 (0x0000007f9fa03000)
    libavdevice.so.59 => /usr/local/lib/libavdevice.so.59 (0x0000007f9f961000)
    libavfilter.so.8 => /usr/local/lib/libavfilter.so.8 (0x0000007f9f61c000)
    libavformat.so.59 => /usr/local/lib/libavformat.so.59 (0x0000007f9f3c2000)
    libavcodec.so.59 => /usr/local/lib/libavcodec.so.59 (0x0000007f9e34c000)
    libswresample.so.4 => /usr/local/lib/libswresample.so.4 (0x0000007f9e327000)
    libswscale.so.6 => /usr/local/lib/libswscale.so.6 (0x0000007f9e2a9000)
    libavutil.so.57 => /usr/local/lib/libavutil.so.57 (0x0000007f9e0fd000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f9e02b000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f9dffc000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f9de8a000)
    libdrm.so.2 => /usr/lib/aarch64-linux-gnu/libdrm.so.2 (0x0000007f9de6a000)
    libxcb.so.1 => /usr/lib/aarch64-linux-gnu/libxcb.so.1 (0x0000007f9de33000)
    libxcb-shm.so.0 => /usr/lib/aarch64-linux-gnu/libxcb-shm.so.0 (0x0000007f9de1f000)
    libxcb-shape.so.0 => /usr/lib/aarch64-linux-gnu/libxcb-shape.so.0 (0x0000007f9de0b000)
    libxcb-xfixes.so.0 => /usr/lib/aarch64-linux-gnu/libxcb-xfixes.so.0 (0x0000007f9ddf3000)
    libbz2.so.1.0 => /lib/aarch64-linux-gnu/libbz2.so.1.0 (0x0000007f9ddd1000)
    libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007f9dda4000)
    liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000007f9dd6f000)
    librockchip_mpp.so.1 => /usr/local/lib/librockchip_mpp.so.1 (0x0000007f9dbbd000)
    librga.so.2 => /usr/lib/aarch64-linux-gnu/librga.so.2 (0x0000007f9dba5000)
    /lib/ld-linux-aarch64.so.1 (0x0000007f9f9d5000)
    libXau.so.6 => /usr/lib/aarch64-linux-gnu/libXau.so.6 (0x0000007f9db92000)
    libXdmcp.so.6 => /usr/lib/aarch64-linux-gnu/libXdmcp.so.6 (0x0000007f9db7c000)
    libstdc++.so.6 => /usr/lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f9d9f1000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f9d9cd000)
    libbsd.so.0 => /usr/lib/aarch64-linux-gnu/libbsd.so.0 (0x0000007f9d9a7000)
    librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007f9d98f000)
root@linaro-alip:~# ffmpeg 
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x559a64ee70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  8.100 / 59.  8.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 16.100 /  8. 16.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

使用 -c:v h264 解码 rtsp 是工作的 ...

root@linaro-alip:~# ffmpeg -c:v h264 -i rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream a.yuv
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x557e024e70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
libavutil      57.  7.100 / 57.  7.100
libavcodec     59. 12.100 / 59. 12.100
libavformat    59.  8.100 / 59.  8.100
libavdevice    59.  0.101 / 59.  0.101
libavfilter     8. 16.100 /  8. 16.100
libswscale      6.  1.100 /  6.  1.100
libswresample   4.  0.100 /  4.  0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream':
Metadata:
title           : HTMS
comment         : h264/ch1/main/av_stream
Duration: N/A, start: 0.009875, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'a.yuv':
Metadata:
title           : HTMS
comment         : h264/ch1/main/av_stream
encoder         : Lavf59.8.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 1920x1080, q=2-31, 622080 kb/s, 25 fps, 25 tbn
Metadata:
encoder         : Lavc59.12.100 rawvideo
frame=   15 fps=4.0 q=-0.0 size=   45312kB time=00:00:00.60 bitrate=618659.8kbits/s speed=0.16x     

使用 -c:v h264_rkmpp 解码 rtsp 是不工作的 ...

root@linaro-alip:~# ffmpeg -c:v h264_rkmpp -i rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream a.yuv
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x559dc2de70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
libavutil      57.  7.100 / 57.  7.100
libavcodec     59. 12.100 / 59. 12.100
libavformat    59.  8.100 / 59.  8.100
libavdevice    59.  0.101 / 59.  0.101
libavfilter     8. 16.100 /  8. 16.100
libswscale      6.  1.100 /  6.  1.100
libswresample   4.  0.100 /  4.  0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream':
Metadata:
title           : HTMS
comment         : h264/ch1/main/av_stream
Duration: N/A, start: 0.006000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264_rkmpp @ 0x559dde0540] Decoder noticed an info change (1920x1080), format=0
一直卡在这里 ...

使用 -v debug -c:v h264_rkmpp 解码 rtsp 是不工作的 ...


root@linaro-alip:~# ffmpeg -v debug -c:v h264_rkmpp -i rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream a.yuv
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x559c93ce70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
libavutil      57.  7.100 / 57.  7.100
libavcodec     59. 12.100 / 59. 12.100
libavformat    59.  8.100 / 59.  8.100
libavdevice    59.  0.101 / 59.  0.101
libavfilter     8. 16.100 /  8. 16.100
libswscale      6.  1.100 /  6.  1.100
libswresample   4.  0.100 /  4.  0.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_rkmpp'.
Reading option '-i' ... matched as input url with argument 'rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream'.
Reading option 'a.yuv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream.
Applying option c:v (codec name) with argument h264_rkmpp.
Successfully parsed a group of options.
Opening an input file: rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream.
[tcp @ 0x559c9400f0] No default whitelist set
[tcp @ 0x559c9400f0] Original list of addresses:
[tcp @ 0x559c9400f0] Address 192.168.0.150 port 554
[tcp @ 0x559c9400f0] Interleaved list of addresses:
[tcp @ 0x559c9400f0] Address 192.168.0.150 port 554
[tcp @ 0x559c9400f0] Starting connection attempt to 192.168.0.150 port 554
[tcp @ 0x559c9400f0] Successfully connected to 192.168.0.150 port 554
[rtsp @ 0x559c93d700] SDP:
v=0
o=- 939819582 1 IN IP4 192.168.0.150
s=HTMS
i=h264/ch1/main/av_stream
e=NONE
t=0 0
a=tool:HTMS
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:HTMS
a=x-qt-text-inf:h264/ch1/main/av_stream
m=video 0 RTP/AVP 96
c=IN IP4 192.168.0.150
b=AS:2
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d0029;sprop-parameter-sets=Z00AKY2NQDwBE/LCAAAOEAACvyAI,aO44gA==
a=control:track=1
a=Media_header:MEDIAINFO=494D4B48010100000400010000000000000000000000000000000000000000000000000000000000;
m=audio 0 RTP/AVP 0
c=IN IP4 0.0.0.0
b=AS:64
a=rtpmap:0 PCMU/8000
a=control:track=2

Failed to parse interval end specification '' [rtsp @ 0x559c93d700] video codec set to: h264 [rtsp @ 0x559c93d700] RTP Packetization Mode: 1 [rtsp @ 0x559c93d700] RTP Profile IDC: 4d Profile IOP: 0 Level: 29 [rtsp @ 0x559c93d700] Extradata set to 0x559c941ee0 (size: 33) [rtsp @ 0x559c93d700] audio codec set to: pcm_mulaw [rtsp @ 0x559c93d700] audio samplerate set to: 8000 [rtsp @ 0x559c93d700] audio channels set to: 1 [rtp @ 0x559c9439b0] No default whitelist set [udp @ 0x559c943d10] No default whitelist set [udp @ 0x559c943d10] end receive buffer size reported is 425984 [udp @ 0x559c953fd0] No default whitelist set [udp @ 0x559c953fd0] end receive buffer size reported is 425984 [rtsp @ 0x559c93d700] setting jitter buffer size to 500 [rtp @ 0x559c964520] No default whitelist set [udp @ 0x559c9647c0] No default whitelist set [udp @ 0x559c9647c0] end receive buffer size reported is 425984 [udp @ 0x559c974a80] No default whitelist set [udp @ 0x559c974a80] end receive buffer size reported is 425984 [rtsp @ 0x559c93d700] setting jitter buffer size to 500 [rtsp @ 0x559c93d700] hello state=0 Failed to parse interval end specification '' [h264 @ 0x559c941a30] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x559c941a30] nal_unit_type: 5(IDR), nal_ref_idc: 3 [h264 @ 0x559c941a30] Format yuv420p chosen by get_format(). [h264 @ 0x559c941a30] Reinit context to 1920x1088, pix_fmt: yuv420p [h264 @ 0x559c941a30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 Last message repeated 5 times [rtsp @ 0x559c93d700] first_dts 25200 not matching first dts NOPTS (pts NOPTS, duration 3600) in the queue [rtsp @ 0x559c93d700] All info found Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream': Metadata: title : HTMS comment : h264/ch1/main/av_stream Duration: N/A, start: 0.005625, bitrate: N/A Stream #0:0, 28, 1/90000: Video: h264 (Main), 1 reference frame, yuv420p(progressive, left), 1920x1080 (1920x1088), 0/1, 25 fps, 25 tbr, 90k tbn Stream #0:1, 29, 1/8000: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s Successfully opened the file. Parsing a group of options: output url a.yuv. Successfully parsed a group of options. Opening an output file: a.yuv. [file @ 0x559c988fb0] Setting default whitelist 'file,crypto,data' Successfully opened the file. [h264_mp4toannexb @ 0x559c93d5d0] The input looks like it is Annex B already [h264_rkmpp @ 0x559cb091f0] Format yuv420p chosen by get_format(). [h264_rkmpp @ 0x559cb091f0] Initializing RKMPP decoder. [h264_rkmpp @ 0x559cb091f0] RKMPP decoder initialized successfully. Stream mapping: Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> rawvideo (native)) Press [q] to stop, [?] for help cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) Last message repeated 1 times [h264_rkmpp @ 0x559cb091f0] Wrote 44646 bytes to decoder [h264_rkmpp @ 0x559cb091f0] Timeout getting decoded frame. Last message repeated 1 times cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) [h264_rkmpp @ 0x559cb091f0] Wrote 8147 bytes to decoder [h264_rkmpp @ 0x559cb091f0] Timeout getting decoded frame. Last message repeated 1 times cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) [h264_rkmpp @ 0x559cb091f0] Wrote 8134 bytes to decoder [h264_rkmpp @ 0x559cb091f0] Timeout getting decoded frame. Last message repeated 1 times cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) [h264_rkmpp @ 0x559cb091f0] Wrote 8264 bytes to decoder [h264_rkmpp @ 0x559cb091f0] Timeout getting decoded frame. Last message repeated 1 times cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) [h264_rkmpp @ 0x559cb091f0] Buffer full [h264_rkmpp @ 0x559cb091f0] Decoder noticed an info change (1920x1080), format=0 [h264_rkmpp @ 0x559cb091f0] Buffer full 一直卡在这里 ...


>使用 -c:v h264_rkmpp 解码本地视频是工作的 ...

root@linaro-alip:~# ffmpeg -c:v h264_rkmpp -i /root/yiyezi.mp4 a.yuv librga:RGA_GET_VERSION:3.02,3.020000 ctx=0x55b4ca2e70,ctx->rgaFd=3 Rga built version:7bf9abf ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga libavutil 57. 7.100 / 57. 7.100 libavcodec 59. 12.100 / 59. 12.100 libavformat 59. 8.100 / 59. 8.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 16.100 / 8. 16.100 libswscale 6. 1.100 / 6. 1.100 libswresample 4. 0.100 / 4. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/root/yiyezi.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:30.05, start: 0.000000, bitrate: 1357 kb/s Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1221 kb/s, 30 fps, 30 tbr, 15360 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> rawvideo (native)) Press [q] to stop, [?] for help [h264_rkmpp @ 0x55b4d598e0] Decoder noticed an info change (1280x720), format=0 Output #0, rawvideo, to 'a.yuv': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf59.8.100 Stream #0:0(und): Video: rawvideo (I420 / 0x30323449), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 331776 kb/s, 30 fps, 30 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc59.12.100 rawvideo frame= 28 fps=8.4 q=-0.0 Lsize= 37800kB time=00:00:00.93 bitrate=331776.1kbits/s dup=1 drop=1 speed=0.281x

JeffyCN commented 2 years ago

从分辨率看测试的片源不同,从log看卡在mpp解码库里面。

所以:1/ 用同样片源测试(比如rtsp片源下载下来本地测试) 2/ 更新mpp(rockchip_mirrors仓库有mpp分支) 3/ 在rkmppdec里面保存输入的数据发出来

nulijiabei commented 2 years ago
我升级了 rockchip_mirrors 仓库中的 mpp 分支

采集的视频文件在 win10 上使用视频播放器是可以正常播放的 ...

使用 JeffyCN/FFmpeg 解码器 -c:v h264 从 RTSP 采集视频文件

root@linaro-alip:~# /usr/local/bin/ffmpeg -c:v h264 -i rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream a.mp4
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x55bcb12e70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  8.100 / 59.  8.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 16.100 /  8. 16.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream':
  Metadata:
    title           : HTMS
    comment         : h264/ch1/main/av_stream
  Duration: N/A, start: 0.005875, bitrate: N/A
  Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
  Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0x55bcb87440] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
Output #0, mp4, to 'a.mp4':
  Metadata:
    title           : HTMS
    comment         : h264/ch1/main/av_stream
    encoder         : Lavf59.8.100
  Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p(progressive), 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn
    Metadata:
      encoder         : Lavc59.12.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s
    Metadata:
      encoder         : Lavc59.12.100 aac
frame=  390 fps= 21 q=31.0 Lsize=    1704kB time=00:00:15.56 bitrate= 897.3kbits/s speed=0.825x     
video:1696kB audio:5kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.192672%
[aac @ 0x55bcb87440] Qavg: 14330.317
Exiting normally, received signal 2.

使用 JeffyCN/FFmpeg 解码器 -c:v h264_rkmpp 转换采集的视频文件

root@linaro-alip:~# /usr/local/bin/ffmpeg -c:v h264_rkmpp -i a.mp4 a.yuv
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x556e97ae70,ctx->rgaFd=3 
Rga built version:7bf9abf 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  8.100 / 59.  8.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 16.100 /  8. 16.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 4 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[h264 @ 0x556e97c4e0] Invalid NAL unit 0, skipping.
[h264 @ 0x556e97c4e0] no frame!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x556e97b6e0] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x556e97b6e0] Could not find codec parameters for stream 0 (Video: h264 (mp4v / 0x7634706D), none, 862 kb/s): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : HTMS
    encoder         : Lavf59.8.100
    comment         : h264/ch1/main/av_stream
  Duration: 00:00:23.48, start: 0.000000, bitrate: 865 kb/s
  Stream #0:0[0x1](und): Video: h264 (mp4v / 0x7634706D), none, 862 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 38 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> rawvideo (native))
Press [q] to stop, [?] for help

使用 JeffyCN/FFmpeg 解码器 -c:v h264 转换采集的视频文件

root@linaro-alip:~# /usr/local/bin/ffmpeg -c:v h264 -i a.mp4 a.yuv
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x55adb32e70,ctx->rgaFd=3 
ffmpeg version git-2022-05-25-73d7bc2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-libdrm --enable-rkmpp --enable-librga
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  8.100 / 59.  8.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 16.100 /  8. 16.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
    Last message repeated 4 times
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
[h264 @ 0x55adb350e0] Invalid NAL unit 0, skipping.
[h264 @ 0x55adb350e0] no frame!
JeffyCN commented 2 years ago

看着像是片源异常或者dump方法不对。可以在pc上同样对比。

一般dump处理可以在rkmppdec里面把packet data在rkmpp_send_packet里面Wrote * bytes to decoder后分别保存到文件。你们的场景大约可以保存出4~5帧的数据。

nulijiabei commented 2 years ago

在 FFmpeg/FFmpeg 4.4.2 使用 h264_rkmpp 解码器在自己的项目中是可以正常解码的 ...

https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.4.2.zip 
./configure --prefix=/usr/local --enable-version3 --disable-static --enable-shared \
        --enable-libdrm --enable-rkmpp --disable-x86asm

rtsp://admin:12345@192.168.0.150:554/h264/ch1/main/av_stream

vCodec = avcodec_find_decoder_by_name("h264_rkmpp");
g_print("FIND DECODER (%s)\n", "h264_rkmpp");
if (vCodec == nullptr) {
g_print("FIND DECODER ERROR !!!\n");
return (nullptr);
}
if (avcodec_open2(vCodecCtx, vCodec, nullptr) < 0) {
g_print("OPEN DECODER ERROR !!!\n");
return (nullptr);
}
// ------------------------------------------------ //
AVPacket *av_packet = av_packet_alloc();
AVFrame *av_frame = av_frame_alloc();
while (av_read_frame(pFormatCtx, av_packet) >= 0 && !cancel) {
if (av_packet->stream_index == videoindex) {
int result = avcodec_send_packet(vCodecCtx, av_packet);
while (!result) {
result = avcodec_receive_frame(vCodecCtx, av_frame);
if (!result) {
AVFrame *avframe = av_frame_alloc();
// 按帧格式判断是否需要转换 ...
if (_frame->format == AV_PIX_FMT_DRM_PRIME) {
// 需要转换 ...
avframe->width = _frame->width;
avframe->height = _frame->height;
avframe->format = AV_PIX_FMT_NV12;
// Copy data to or from a hw surface ...
av_hwframe_transfer_data(avframe, _frame, 0); // 转换
} else {
// 无需转换 ...
av_frame_ref(avframe, _frame);
}

[tcp @ 0x7f84004070] No default whitelist set
[tcp @ 0x7f84004070] Original list of addresses:
[tcp @ 0x7f84004070] Address 192.168.0.150 port 554
[tcp @ 0x7f84004070] Interleaved list of addresses:
[tcp @ 0x7f84004070] Address 192.168.0.150 port 554
[tcp @ 0x7f84004070] Starting connection attempt to 192.168.0.150 port 554
[tcp @ 0x7f84004070] Successfully connected to 192.168.0.150 port 554
[rtsp @ 0x7f840013e0] SDP:
v=0
o=- 1637840187 1 IN IP4 192.168.0.150
s=HTMS
i=h264/ch1/main/av_stream
e=NONE
t=0 0
a=tool:HTMS
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:HTMS
a=x-qt-text-inf:h264/ch1/main/av_stream
m=video 0 RTP/AVP 96
c=IN IP4 192.168.0.150
b=AS:2
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d0029;sprop-parameter-sets=Z00AKY2NQDwBE/LCAAAOEAACvyAI,aO44gA==
a=control:track=1
a=Media_header:MEDIAINFO=494D4B48010100000400010000000000000000000000000000000000000000000000000000000000;
m=audio 0 RTP/AVP 0
c=IN IP4 0.0.0.0
b=AS:64
a=rtpmap:0 PCMU/8000
a=control:track=2

Failed to parse interval end specification '' [rtsp @ 0x7f840013e0] video codec set to: h264 [rtsp @ 0x7f840013e0] RTP Packetization Mode: 1 [rtsp @ 0x7f840013e0] RTP Profile IDC: 4d Profile IOP: 0 Level: 29 [rtsp @ 0x7f840013e0] Extradata set to 0x7f840063b0 (size: 33) [rtsp @ 0x7f840013e0] audio codec set to: pcm_mulaw [rtsp @ 0x7f840013e0] audio samplerate set to: 8000 [rtsp @ 0x7f840013e0] audio channels set to: 1 [rtp @ 0x7f84008440] No default whitelist set [udp @ 0x7f840087a0] No default whitelist set [udp @ 0x7f840087a0] end receive buffer size reported is 425984 [udp @ 0x7f84008840] No default whitelist set [udp @ 0x7f84008840] end receive buffer size reported is 425984 [rtsp @ 0x7f840013e0] setting jitter buffer size to 500 [rtp @ 0x7f84008ba0] No default whitelist set [udp @ 0x7f84008e40] No default whitelist set [udp @ 0x7f84008e40] end receive buffer size reported is 425984 [udp @ 0x7f84039620] No default whitelist set [udp @ 0x7f84039620] end receive buffer size reported is 425984 [rtsp @ 0x7f840013e0] setting jitter buffer size to 500 [rtsp @ 0x7f840013e0] hello state=0 Failed to parse interval end specification '' [h264 @ 0x7f84005f50] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f84005f50] nal_unit_type: 5(IDR), nal_ref_idc: 3 [h264 @ 0x7f84005f50] Format yuv420p chosen by get_format(). [h264 @ 0x7f84005f50] Reinit context to 1920x1088, pix_fmt: yuv420p [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f84005f50] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [rtsp @ 0x7f840013e0] All info found FIND DECODER (h264_rkmpp) [h264_mp4toannexb @ 0x7f84003ee0] The input looks like it is Annex B already [h264_rkmpp @ 0x7f84005850] Initializing RKMPP decoder. mpp[1157]: mpp_info: mpp version: 7ce408f4 author: Caesar Wang 2020-11-19 Revert "[vdpu2]: fix bug: set ref list" mpp[1157]: mpp_rt: NOT found ion allocator mpp[1157]: mpp_rt: found drm allocator mpp[1157]: mpp: deprecated block control, use timeout control instead mpp[1157]: mpp: deprecated block control, use timeout control instead [h264_rkmpp @ 0x7f84005850] RKMPP decoder initialized successfully. [h264_rkmpp @ 0x7f84005850] Wrote 33 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 17931 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 82 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 81 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 85 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 405 bytes to decoder [h264_rkmpp @ 0x7f84005850] Decoder noticed an info change (1920x1080), format=0 [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 90 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 141 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 94 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 204 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 266 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 157 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 158 bytes to decoder [h264_rkmpp @ 0x7f84005850] Wrote 147 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Received a frame. [h264_rkmpp @ 0x7f84005850] Wrote 145 bytes to decoder [h264_rkmpp @ 0x7f84005850] Received a frame.


> 系统内置的 mpp 1.3.8 在 FFmpeg/FFmpeg 4.4.2 中可以使用 ...
> 在使用 JeffyCN/FFmpeg 需要升级最新的 rockchip_mirrors/mpp 才可以
在 JeffyCN/FFmpeg 4.4 使用 h264_rkmpp 解码器时不工作 ...

librga:RGA_GET_VERSION:3.02,3.020000 ctx=0x5590846350,ctx->rgaFd=3 Rga built version:7bf9abf

x_offset(0) y_offset(0) width(512) height(512) format(17301505) <<< [tcp @ 0x7f9c003c60] No default whitelist set [tcp @ 0x7f9c003c60] Original list of addresses: [tcp @ 0x7f9c003c60] Address 192.168.0.150 port 554 [tcp @ 0x7f9c003c60] Interleaved list of addresses: [tcp @ 0x7f9c003c60] Address 192.168.0.150 port 554 [tcp @ 0x7f9c003c60] Starting connection attempt to 192.168.0.150 port 554 [tcp @ 0x7f9c003c60] Successfully connected to 192.168.0.150 port 554 [rtsp @ 0x7f9c000fd0] SDP: v=0 o=- 185963953 1 IN IP4 192.168.0.150 s=HTMS i=h264/ch1/main/av_stream e=NONE t=0 0 a=tool:HTMS a=type:broadcast a=control:* a=range:npt=0- a=x-qt-text-nam:HTMS a=x-qt-text-inf:h264/ch1/main/av_stream m=video 0 RTP/AVP 96 c=IN IP4 192.168.0.150 b=AS:2 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=4d0029;sprop-parameter-sets=Z00AKY2NQDwBE/LCAAAOEAACvyAI,aO44gA== a=control:track=1 a=Media_header:MEDIAINFO=494D4B48010100000400010000000000000000000000000000000000000000000000000000000000; m=audio 0 RTP/AVP 0 c=IN IP4 0.0.0.0 b=AS:64 a=rtpmap:0 PCMU/8000 a=control:track=2

Failed to parse interval end specification '' [rtsp @ 0x7f9c000fd0] video codec set to: h264 [rtsp @ 0x7f9c000fd0] RTP Packetization Mode: 1 [rtsp @ 0x7f9c000fd0] RTP Profile IDC: 4d Profile IOP: 0 Level: 29 [rtsp @ 0x7f9c000fd0] Extradata set to 0x7f9c005fa0 (size: 33) [rtsp @ 0x7f9c000fd0] audio codec set to: pcm_mulaw [rtsp @ 0x7f9c000fd0] audio samplerate set to: 8000 [rtsp @ 0x7f9c000fd0] audio channels set to: 1 [rtp @ 0x7f9c008030] No default whitelist set [udp @ 0x7f9c008390] No default whitelist set [udp @ 0x7f9c008390] end receive buffer size reported is 425984 [udp @ 0x7f9c008430] No default whitelist set [udp @ 0x7f9c008430] end receive buffer size reported is 425984 [rtsp @ 0x7f9c000fd0] setting jitter buffer size to 500 [rtp @ 0x7f9c008790] No default whitelist set [udp @ 0x7f9c008a30] No default whitelist set [udp @ 0x7f9c008a30] end receive buffer size reported is 425984 [udp @ 0x7f9c008ad0] No default whitelist set [udp @ 0x7f9c008ad0] end receive buffer size reported is 425984 [rtsp @ 0x7f9c000fd0] setting jitter buffer size to 500 [rtsp @ 0x7f9c000fd0] hello state=0 Failed to parse interval end specification '' [h264 @ 0x7f9c005b40] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 7(SPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 8(PPS), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] nal_unit_type: 5(IDR), nal_ref_idc: 3 [h264 @ 0x7f9c005b40] Format yuv420p chosen by get_format(). [h264 @ 0x7f9c005b40] Reinit context to 1920x1088, pix_fmt: yuv420p [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [h264 @ 0x7f9c005b40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2 [rtsp @ 0x7f9c000fd0] All info found FIND DECODER (h264_rkmpp) [h264_mp4toannexb @ 0x7f9c003ad0] The input looks like it is Annex B already [h264_rkmpp @ 0x7f9c005440] Format yuv420p chosen by get_format(). [h264_rkmpp @ 0x7f9c005440] Initializing RKMPP decoder. [h264_rkmpp @ 0x7f9c005440] RKMPP decoder initialized successfully. [h264_rkmpp @ 0x7f9c005440] Wrote 18012 bytes to decoder [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Wrote 87 bytes to decoder [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Wrote 87 bytes to decoder [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Wrote 87 bytes to decoder [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Timeout getting decoded frame. [h264_rkmpp @ 0x7f9c005440] Buffer full [h264_rkmpp @ 0x7f9c005440] Decoder noticed an info change (1920x1080), format=0 [h264_rkmpp @ 0x7f9c005440] Buffer full

JeffyCN commented 2 years ago

please check my latest reply.

JeffyCN commented 2 years ago

'1/ 用同样片源测试(比如rtsp片源下载下来本地测试) 2/ 更新mpp(rockchip_mirrors仓库有mpp分支) 3/ 在rkmppdec里面保存输入的数据发出来'

'一般dump处理可以在rkmppdec里面把packet data在rkmpp_send_packet里面Wrote * bytes to decoder后分别保存到文件。你们的场景大约可以保存出4~5帧的数据。'

JeffyCN commented 1 year ago

FYI, we found an issue that the mpp might not be able to return frames with the starting 4 packets for some streams.

I've pushed a workaround for it:

+++ b/libavcodec/rkmppdec.c
@@ -721,8 +721,10 @@ static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
             // send pending data to decoder
             ret = rkmpp_send_packet(avctx, packet);
             if (ret == AVERROR(EAGAIN)) {
-                // blocked polling since we got enough data
-                return rkmpp_get_frame(avctx, frame, MPP_TIMEOUT_BLOCK);
+                // some streams might need more packets to start returning frame
+                ret = rkmpp_get_frame(avctx, frame, 1);
+                if (ret != AVERROR(EAGAIN))
+                    return ret;
             } else if (ret < 0) {