rockchip-linux / mpp

Media Process Platform (MPP) module
587 stars 169 forks source link

Failed to initialize MPP context #387

Open danergo opened 1 year ago

danergo commented 1 year ago

I compiled this repo: https://github.com/jjm2473/ffmpeg-rk, on NanoPI R5C.

However, when I run, I got these errors:

[hevc_rkmpp @ 0x55a919c7e0] Failed to initialize MPP context (code = -1).
[hevc_rkmpp @ 0x55a919c7e0] Failed to initialize RKMPP decoder.

Can you help me resolving these? I compiled mpp from your repository with:

cmake -DRKPLATFORM=ON -DHAVE_DRM=ON  -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
sudo ldconfig

Thank you

danergo commented 1 year ago

?

HermanChen commented 1 year ago

please provide more log

danergo commented 1 year ago

I think I resolved this by running ffmpeg with sudo, so file permissions are wrong by default.

Also I have to manually remove /dev/ion after bootup to prevent these initialization failures.

Is ion not working correctly on Debian Bullseye with kernel 5.10.110?

danergo commented 1 year ago

However, please review my ffmpeg transcode trial with ffmpeg_rk:

My problem is in spite of RK3568 was being marketed to support full hardware decoding and encoding of hevc and h264, this command can't even reach 1x speed (ends around 0.7x speed which is far from realtime):

$ sudo ffmpeg -benchmark -vcodec hevc_rkmpp -i ../DJI_0181.MP4 -vf 'scale_rga' -vcodec h264_rkmpp -q:v 80 -f null -
ffmpeg version N-104499-g646d5566ac Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --disable-libx264 --disable-libopenh264 --disable-decoder=h264_v4l2m2m --disable-decoder=vp8_v4l2m2m --disable-decoder=mpeg2_v4l2m2m --disable-decoder=mpeg4_v4l2m2m --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-gpl --enable-version3 --enable-nonfree --enable-libdrm --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-libfdk-aac --enable-librga --enable-rkmpp
  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
  libpostproc    56.  0.100 / 56.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55a21032a0] stream 0, timescale not set
[hevc @ 0x55a2117a40] PPS id out of range: 65498
[hevc @ 0x55a2117a40] Error parsing NAL unit #0.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55a21032a0] Stream #4: not enough frames to estimate rate; consider increasing probesize
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55a21032a0] decoding for stream 4 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55a21032a0] Could not find codec parameters for stream 4 (Video: hevc, none): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../DJI_0181.MP4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 2023-04-08T14:53:45.000000Z
    encoder         : DJIAction2
  Duration: 00:09:26.74, start: 0.000000, bitrate: 53480 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160, 51156 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -180.00 degrees
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Data: none (djmd / 0x646D6A64), 9 kb/s
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : DJI meta
  Stream #0:3[0x4](und): Data: none (dbgi / 0x69676264), 1976 kb/s
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : DJI dbgi
  Stream #0:4[0x0]: Video: hevc, none, 90k tbr, 90k tbn (attached pic)
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_rkmpp) -> h264 (h264_rkmpp))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[hevc_rkmpp @ 0x55a214f4e0] Decoder noticed an info change (3840x2160), stride(3840x2160), format=0
[h264_rkmpp @ 0x55a2178ea0] Unsupport profile -99, force set to 100
[h264_rkmpp @ 0x55a2178ea0] Unsupport level -99, force set to 51
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.8.100
  Stream #0:0(und): Video: h264, drm_prime(tv, bt709, progressive), 3840x2160, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn (default)
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.12.100 h264_rkmpp
    Side data:
      displaymatrix: rotation of -0.00 degrees
  Stream #0:1(und): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2023-04-08T14:53:45.000000Z
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.12.100 pcm_s16le
[null @ 0x55a21786b0] Encoder did not produce proper pts, making some up.
frame=  664 fps= 18 q=-0.0 Lsize=N/A time=00:00:28.71 bitrate=N/A speed=0.789x
video:28889kB audio:5384kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=2.971s stime=1.667s rtime=36.406s
bench: maxrss=26152kB

Journal:

Apr 23 10:54:44 nanopi sudo[5837]:       pi : TTY=pts/0 ; PWD=/home/pi/work/ffmpeg/ffmpeg-rk ; USER=root ; COMMAND=/usr/bin/ffmpeg -benchmark -vcodec hevc_rkmpp -i ../DJI_0181.MP4 -vf scale_rga -vcodec h264_rkmpp -q:v 80 -f null -
Apr 23 10:54:44 nanopi sudo[5837]: pam_unix(sudo:session): session opened for user root(uid=0) by pi(uid=1000)
Apr 23 10:54:44 nanopi mpp[5838]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 23 10:54:44 nanopi mpp[5838]: H265D_PARSER: No start code is found.
Apr 23 10:54:44 nanopi mpp[5838]: mpp_buf_slot: set frame info: w 3840 h 2160 hor 3840 ver 2160
Apr 23 10:54:44 nanopi mpp[5838]: mpp_dec: setting default w 3840 h 2160 h_str 3840 v_str 2160
Apr 23 10:54:44 nanopi kernel: devfreq fdf80200.rkvdec: Couldn't update frequency transition information.
Apr 23 10:54:44 nanopi mpp[5838]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 23 10:54:44 nanopi mpp[5838]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [3840:2160] stride [3840:2160]
Apr 23 10:54:44 nanopi mpp[5838]: mpp_enc: mode vbr bps [1500000:2000000:2500000] fps fix [30/1] -> fix [30/1] gop i [60] v [0]
Apr 23 10:54:44 nanopi mpp[5838]: mpp_enc: MPP_ENC_SET_RC_CFG bps 200000 [0 : 0] fps [24000:24000] gop 12
Apr 23 10:54:44 nanopi mpp[5838]: mpp_enc: mode fixqp bps [0:200000:0] fps fix [24000/1001] -> fix [24000/1001] gop i [12] v [0]
Apr 23 10:55:20 nanopi mpp[5838]: mpp_task_impl: mpp_task_queue_deinit input queue idx 0 task 0x55a218bbe0 status 0 meta size 1
Apr 23 10:55:20 nanopi mpp[5838]: mpp_meta: dumping meta 8 node count 1
Apr 23 10:55:20 nanopi mpp[5838]: mpp_meta: key ifrm type mfrm
Apr 23 10:55:20 nanopi mpp[5838]: mpp_buffer: ~MppBufferService cleaning misc group
Apr 23 10:55:20 nanopi ffmpeg[5838]: mpp_mem_pool: put_pool found 1 used buffer size 304
Apr 23 10:55:20 nanopi sudo[5837]: pam_unix(sudo:session): session closed for user root

Can you have any idea for me to use this board better?

Thank you