jjm2473 / ffmpeg-rk

支持rockchip mpp硬件加速编解码的ffmpeg版本。Forked ffmpeg that supports rkmpp decodeing, encoding and rga scaling
https://ffmpeg.org
Other
178 stars 31 forks source link

libx264.so.155: cannot open shared object file: No such file or directory #6

Closed danergo closed 1 year ago

danergo commented 1 year ago

I compiled everything based on my best knowledge collected from multiple places as you didn't specified here where you have libraries from:

1.) librga: from https://github.com/JeffyCN/rockchip_mirrors (linux-rga tree) 2.) mpp: from https://github.com/JeffyCN/rockchip_mirrors (mpp tree) 3.) ffmpeg: from your repo

Compile step:

./configure --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-gpl --enable-libx264 --enable-version3 --enable-nonfree --enable-libdrm --enable-librga --enable-rkmpp --enable-libfdk-aac

Make and install steps:

1.) make -j4 2.) sudo make install

Target: NanoPI R5C (RK3568B2).

However after compile, build, install and reboot steps, I got this strange error:

$ ffmpeg
ffmpeg: error while loading shared libraries: libx264.so.155: cannot open shared object file: No such file or directory

Where shall I download this from?

Because:

$ sudo apt install libx264-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libx264-dev is already the newest version (2:0.160.3011+gitcde9a93-2.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
jjm2473 commented 1 year ago

we don't need libx264

jjm2473 commented 1 year ago

https://github.com/jjm2473/ffmpeg-rk/wiki#eng

danergo commented 1 year ago

I compiled with this:

./configure --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-pthreads --enable-zlib --disable-doc --enable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-gpl --disable-libx264 --enable-version3 --enable-nonfree --enable-libdrm --enable-librga --enable-rkmpp --enable-libfdk-aac

--disable-libx264 !!

But when I run:

ffmpeg: error while loading shared libraries: libx264.so.155: cannot open shared object file: No such file or directory

Can you tell me the exact configure line please?

danergo commented 1 year ago

@jjm2473

./configure --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-pthreads --enable-zlib --disable-doc --enable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-gpl --disable-libx264 --enable-version3 --enable-nonfree --enable-libdrm --enable-librga --enable-rkmpp --enable-libfdk-aac --disable-libopenh264 --disable-vaapi --disable-vdpau --disable-decoder=h264_v4l2m2m --disable-decoder=vp8_v4l2m2m --disable-decoder=mpeg2_v4l2m2m --disable-decoder=mpeg4_v4l2m2m

Still missing libx264.so.155 !!!

I had to manually copy my libx264.so.160 to libx264.so.155 to run your ffmpeg:

$ sudo ffmpeg -loglevel debug -benchmark -vcodec h264_rkmpp -i ../Big_Buck_Bunny_1080_10s_30MB.mp4 -map 0:v:0 -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 --enable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-gpl --disable-libx264 --enable-version3 --enable-nonfree --enable-libdrm --enable-librga --enable-rkmpp --enable-libfdk-aac --disable-libopenh264 --disable-vaapi --disable-vdpau --disable-decoder=h264_v4l2m2m --disable-decoder=vp8_v4l2m2m --disable-decoder=mpeg2_v4l2m2m --disable-decoder=mpeg4_v4l2m2m
  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
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-benchmark' ... matched as option 'benchmark' (add timings for benchmarking) with argument '1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264_rkmpp'.
Reading option '-i' ... matched as input url with argument '../Big_Buck_Bunny_1080_10s_30MB.mp4'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:v:0'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '-' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option benchmark (add timings for benchmarking) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url ../Big_Buck_Bunny_1080_10s_30MB.mp4.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264_rkmpp.
Successfully parsed a group of options.
Opening an input file: ../Big_Buck_Bunny_1080_10s_30MB.mp4.
[NULL @ 0x55665172b0] Opening '../Big_Buck_Bunny_1080_10s_30MB.mp4' for reading
[file @ 0x5566517720] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Processing st: 0, edit list 0 - media time: 1024, duration: 153600
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Offset DTS by 1024 to make first pts zero.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Setting codecpar->delay to 2 for stream st: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] Before avformat_find_stream_info() pos: 4676 bytes read:32768 seeks:0 nb_streams:1
[h264 @ 0x5566517dd0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x5566517dd0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x5566517dd0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x5566517dd0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x5566517dd0] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x5566517dd0] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x5566517dd0] Format yuv420p chosen by get_format().
[h264 @ 0x5566517dd0] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x5566517dd0] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55665172b0] After avformat_find_stream_info() pos: 1162504 bytes read:1162504 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../Big_Buck_Bunny_1080_10s_30MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 24563 kb/s
  Stream #0:0[0x1](und), 1, 1/15360: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 0/1, 24559 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url -.
Applying option map (set input stream mapping) with argument 0:v:0.
Applying option f (force format) with argument null.
Successfully parsed a group of options.
Opening an output file: -.
Successfully opened the file.
[h264_rkmpp @ 0x556653cb20] Initializing RKMPP decoder.
[h264_rkmpp @ 0x556653cb20] Failed to initialize MPP context (code = -1).
[h264_rkmpp @ 0x556653cb20] Failed to initialize RKMPP decoder.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_rkmpp) -> wrapped_avframe (native))
Error while opening decoder for input stream #0:0 : Unknown error occurred
bench: maxrss=22968kB
[AVIOContext @ 0x556651f7f0] Statistics: 1162504 bytes read, 0 seeks

Failed to initialize MPP context (code = -1). !!!

$ ls -all /dev/mpp_service
crw-rw-rw- 1 root root 241, 0 Aug  7  2022 /dev/mpp_service

$ ls -all /dev/rga
crw-rw-rw- 1 root root 10, 119 Aug  7  2022 /dev/rga

I don't have / want docker. I just want an ffmpeg can use this *** architecture's hw.

danergo commented 1 year ago
Apr 22 14:23:32 nanopi sudo[824]:       pi : TTY=pts/0 ; PWD=/home/pi/work/ffmpeg ; USER=root ; COMMAND=/usr/bin/ffmpeg -loglevel debug -benchmark -vcodec h264_rkmpp -i Big_Buck_Bunny_1080_10s_30MB.mp4 -map 0:v:0 -f null -
Apr 22 14:23:32 nanopi sudo[824]: pam_unix(sudo:session): session opened for user root(uid=0) by pi(uid=1000)
Apr 22 14:23:33 nanopi mpp[825]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /proc/device-tree for vpu_service return 0
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /proc/device-tree for hevc_service return 0
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: Assertion n == 1 failed at find_dir_in_path:194
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /proc/device-tree/rkvdec-opp-table for iommu_enabled return 0
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: Assertion n == 1 failed at find_dir_in_path:194
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /proc/device-tree/rkvenc-opp-table for iommu_enabled return 0
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /proc/device-tree for vpu_combo return 0
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /sys/kernel/debug/ion/heaps for vmalloc return -1
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: scan /sys/kernel/debug/ion/heaps for system-heap return -1
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: can not find any hint from all possible devices
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: using ion heap ION_HEAP_TYPE_CARVEOUT
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: ion_ioctl c0204900 failed with code -1: Invalid argument
Apr 22 14:23:33 nanopi mpp[825]: mpp_ion: allocator_ion_alloc ion_alloc failed ret -22
Apr 22 14:23:33 nanopi mpp[825]: mpp_buffer: mpp_buffer_create failed to create buffer with size 77824
Apr 22 14:23:33 nanopi mpp[825]: mpp_buffer: mpp_buffer_put invalid input: buffer NULL from vdpu34x_h264d_deinit
Apr 22 14:23:33 nanopi mpp[825]: mpp_hal: mpp_hal_init hal h264d_rkdec init failed ret -1
Apr 22 14:23:33 nanopi mpp[825]: mpp_hal: mpp_hal_init could not found coding type 7
Apr 22 14:23:33 nanopi mpp[825]: mpp_dec: mpp_dec_init could not init hal
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 14:23:33 nanopi mpp[825]: mpp: error found on mpp initialization
Apr 22 14:23:33 nanopi mpp[825]: mpp_buffer: ~MppBufferService cleaning leaked group
Apr 22 14:23:33 nanopi ffmpeg[825]: mpp_mem_pool: put_pool found 4 used buffer size 224
jjm2473 commented 1 year ago

try delete /dev/ion

jjm2473 commented 1 year ago

Oh, yes, libx264 is needed: https://github.com/jjm2473/packages/blob/istoreos-21.02/multimedia/ffmpeg-mpp/Makefile

jjm2473 commented 1 year ago

/dev/dri or /dev/dma_heap must exist at least one, and /dev/ion cannot exist, if there is, delete it.

jjm2473 commented 1 year ago

Maybe MPP library has troubles with ION memory allocator.

danergo commented 1 year ago

Okay, thank you.

I had /dev/ion, and I deleted it.

Now during retest, I am still getting MPP initialization error, and these are the lines in journalctl:


Apr 22 16:23:26 nanopi mpp[2269]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 22 16:23:26 nanopi mpp[2269]: mpp_dma_heap: Assertion fd > 0 failed at heap_fd_open:136
Apr 22 16:23:26 nanopi mpp[2269]: mpp_dma_heap: os_allocator_dma_heap_open open dma heap type 0 failed!
Apr 22 16:23:26 nanopi mpp[2269]: mpp_allocator: mpp_allocator_get type 1 failed
Apr 22 16:23:26 nanopi mpp[2269]: mpp_buffer: Assertion p->allocator failed at get_group:936
Apr 22 16:23:26 nanopi mpp[2269]: mpp_buffer: Assertion p->alloc_api failed at get_group:937
Apr 22 16:23:26 nanopi mpp[2269]: vcodec_service: open vcodec_service /dev/mpp_service failed
Apr 22 16:23:26 nanopi mpp[2269]: hal_h264d_api: mpp_dev_init failed ret: -1
Apr 22 16:23:26 nanopi mpp[2269]: mpp_hal: mpp_hal_init hal h264d_rkdec init failed ret -1
Apr 22 16:23:26 nanopi mpp[2269]: mpp_hal: mpp_hal_init could not found coding type 7
Apr 22 16:23:26 nanopi mpp[2269]: mpp_dec: mpp_dec_init could not init hal
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp_time: mpp_clock_put invalid clock (nil)
Apr 22 16:23:26 nanopi mpp[2269]: mpp: error found on mpp initialization
Apr 22 16:23:26 nanopi ffmpeg[2269]: mpp_mem_pool: put_pool found 4 used buffer size 224
danergo commented 1 year ago

Okay, some result finally:

After chmod 666 /dev/mpp_service:

$ ffmpeg -loglevel debug -benchmark -vcodec h264_rkmpp -i Big_Buck_Bunny_1080_10s_30MB.mp4 -map 0:v:0 -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 --enable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-neon --enable-vfp --enable-gnutls --enable-libopus --enable-hardcoded-tables --enable-libmp3lame --enable-gpl --disable-libx264 --enable-version3 --enable-nonfree --enable-libdrm --enable-librga --enable-rkmpp --enable-libfdk-aac --disable-libopenh264 --disable-vaapi --disable-vdpau --disable-decoder=h264_v4l2m2m --disable-decoder=vp8_v4l2m2m --disable-decoder=mpeg2_v4l2m2m --disable-decoder=mpeg4_v4l2m2m
  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
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-benchmark' ... matched as option 'benchmark' (add timings for benchmarking) with argument '1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264_rkmpp'.
Reading option '-i' ... matched as input url with argument 'Big_Buck_Bunny_1080_10s_30MB.mp4'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:v:0'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '-' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option benchmark (add timings for benchmarking) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url Big_Buck_Bunny_1080_10s_30MB.mp4.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264_rkmpp.
Successfully parsed a group of options.
Opening an input file: Big_Buck_Bunny_1080_10s_30MB.mp4.
[NULL @ 0x55b22282b0] Opening 'Big_Buck_Bunny_1080_10s_30MB.mp4' for reading
[file @ 0x55b2228720] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Processing st: 0, edit list 0 - media time: 1024, duration: 153600
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Offset DTS by 1024 to make first pts zero.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Setting codecpar->delay to 2 for stream st: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] Before avformat_find_stream_info() pos: 4676 bytes read:32768 seeks:0 nb_streams:1
[h264 @ 0x55b2228dd0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55b2228dd0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55b2228dd0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55b2228dd0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55b2228dd0] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x55b2228dd0] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x55b2228dd0] Format yuv420p chosen by get_format().
[h264 @ 0x55b2228dd0] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x55b2228dd0] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b22282b0] After avformat_find_stream_info() pos: 1162504 bytes read:1162504 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Big_Buck_Bunny_1080_10s_30MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 24563 kb/s
  Stream #0:0[0x1](und), 1, 1/15360: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 0/1, 24559 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url -.
Applying option map (set input stream mapping) with argument 0:v:0.
Applying option f (force format) with argument null.
Successfully parsed a group of options.
Opening an output file: -.
Successfully opened the file.
[h264_rkmpp @ 0x55b224db20] Initializing RKMPP decoder.
Segmentation fault

journal:

Apr 22 16:29:05 nanopi mpp[2331]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 22 16:29:05 nanopi mpp[2331]: mpp_dma_heap: Assertion fd > 0 failed at heap_fd_open:136
Apr 22 16:29:05 nanopi mpp[2331]: mpp_dma_heap: os_allocator_dma_heap_open open dma heap type 0 failed!
Apr 22 16:29:05 nanopi mpp[2331]: mpp_allocator: mpp_allocator_get type 1 failed
Apr 22 16:29:05 nanopi mpp[2331]: mpp_buffer: Assertion p->allocator failed at get_group:936
Apr 22 16:29:05 nanopi mpp[2331]: mpp_buffer: Assertion p->alloc_api failed at get_group:937
Apr 22 16:29:05 nanopi mpp[2331]: mpp_dma_heap: Assertion fd > 0 failed at heap_fd_open:136
Apr 22 16:29:05 nanopi mpp[2331]: mpp_dma_heap: os_allocator_dma_heap_open open dma heap type 0 failed!
Apr 22 16:29:05 nanopi mpp[2331]: mpp_allocator: mpp_allocator_get type 1 failed
Apr 22 16:29:05 nanopi mpp[2331]: mpp_buffer: Assertion p->allocator failed at get_group:936
Apr 22 16:29:05 nanopi mpp[2331]: mpp_buffer: Assertion p->alloc_api failed at get_group:937

What do you suggest?

danergo commented 1 year ago

I had libx264.so.160 and I didn't have better idea than creating a symlink to it with libx264.so.155 name (which ffmpeg was looking for).

This is a bad idea, I know, but I wanted to see ffmpeg starting.

Now, as it is starting, can you recommend me a way to get libx264.so.155, or even better, how can I change this dependency to libx264.so.160?

Thank you.

danergo commented 1 year ago

If I run with sudo, it finally succeeds!! :))

Can you help me, which exact permissions are needed to avoid sudo?

$ mpi_dec_test -i Big_Buck_Bunny_1080_10s_30MB_track1.h264
Segmentation fault

Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: input file Big_Buck_Bunny_1080_10s_30MB_track1.h264 size 30699878
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: cmd parse result:
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: input  file name: Big_Buck_Bunny_1080_10s_30MB_track1.h264
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: output file name:
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: width      :    0
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: height     :    0
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: type       :    7
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_utils: max frames :    0
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_test: mpi_dec_test start
Apr 22 17:04:32 nanopi mpp[2868]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 22 17:04:32 nanopi mpp[2868]: mpi_dec_test: 0x558047a2c0 mpi_dec_test decoder test start w 0 h 0 type 7
Apr 22 17:04:32 nanopi mpp[2868]: mpp_dma_heap: Assertion fd > 0 failed at heap_fd_open:136
Apr 22 17:04:32 nanopi mpp[2868]: mpp_dma_heap: os_allocator_dma_heap_open open dma heap type 0 failed!
Apr 22 17:04:32 nanopi mpp[2868]: mpp_allocator: mpp_allocator_get type 1 failed
Apr 22 17:04:32 nanopi mpp[2868]: mpp_buffer: Assertion p->allocator failed at get_group:936
Apr 22 17:04:32 nanopi mpp[2868]: mpp_buffer: Assertion p->alloc_api failed at get_group:937
Apr 22 17:04:32 nanopi mpp[2868]: mpp_dma_heap: Assertion fd > 0 failed at heap_fd_open:136
Apr 22 17:04:32 nanopi mpp[2868]: mpp_dma_heap: os_allocator_dma_heap_open open dma heap type 0 failed!
Apr 22 17:04:32 nanopi mpp[2868]: mpp_allocator: mpp_allocator_get type 1 failed
Apr 22 17:04:32 nanopi mpp[2868]: mpp_buffer: Assertion p->allocator failed at get_group:936
Apr 22 17:04:32 nanopi mpp[2868]: mpp_buffer: Assertion p->alloc_api failed at get_group:937

With sudo it's okay.

I wish to fix these 2 things: 1.) make it work without sudo 2.) Compile libx264.so.155 or update ffmpeg to use libx264.so.160.

Please help me resolving these two points.

Thank you very much!

jjm2473 commented 1 year ago

Nothing related on libx264, try change permissions of /dev/mpp_service , /dev/dma_heap or /dev/dri/*.

If you'r not sure what file permission failed, just use strace util to trace file open.

jjm2473 commented 1 year ago

I don't know why you have trouble with libx264, do you use the same version of libx264 on compiling and runtime?

DO NOT ask me about libx264 again, it's not related my project.

danergo commented 1 year ago

I don't know why you have trouble with libx264, do you use the same version of libx264 on compiling and runtime?

DO NOT ask me about libx264 again, it's not related my project.

Okay sorry.

I am compiling on the NanoPi itself.

Thanks for the strace, will try

danergo commented 1 year ago

Just one more question: I got massive logging in journalctl, by kernel about "mpp_rkvdec2", and "rk_iommu".

Can I somehow disable these logging (because it causes high CPU usage on one core during transcode).

Thank you very much!

danergo commented 1 year ago

Oh, and some again:

$ sudo ffmpeg -benchmark -vcodec hevc_rkmpp -i ../DJI_0181.MP4 -vf 'scale_rga=w=1920:h=1080' -vcodec h264_rkmpp -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 @ 0x5583c56280] stream 0, timescale not set
[hevc @ 0x5583c6aa20] PPS id out of range: 65498
[hevc @ 0x5583c6aa20] Error parsing NAL unit #0.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5583c56280] Stream #4: not enough frames to estimate rate; consider increasing probesize
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5583c56280] decoding for stream 4 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5583c56280] 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 @ 0x5583ca24c0] Decoder noticed an info change (3840x2160), stride(3840x2160), format=0
rga_api version 1.3.1_[11] (1e2f0db build: 2023-04-20 13:33:00 base: )
 RgaBlit(1356) RGA_BLIT fail: Invalid argument RgaBlit(1357) RGA_BLIT fail: Invalid argument
fd-vir-phy-hnd-format[9, (nil), (nil), (nil), 0]
rect[0, 0, 3840, 2160, 3840, 2160, 2560, 0]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
fd-vir-phy-hnd-format[22, (nil), (nil), (nil), 0]
rect[0, 0, 1920, 1080, 1920, 1080, 2560, 3110400]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
This output the user patamaters when rga call blit fail
[scale_rga @ 0x5583cea300] RGA failed (code = -22)
free(): double free detected in tcache 2
Aborted

And in journal:

Apr 22 21:15:21 nanopi mpp[16808]: mpp_info: mpp version: da6ad1ee author: Herman Chen   2023-03-09 [LICENSE]: Add MIT license to some code
Apr 22 21:15:21 nanopi mpp[16808]: H265D_PARSER: No start code is found.
Apr 22 21:15:21 nanopi mpp[16808]: mpp_buf_slot: set frame info: w 3840 h 2160 hor 3840 ver 2160
Apr 22 21:15:21 nanopi mpp[16808]: mpp_dec: setting default w 3840 h 2160 h_str 3840 v_str 2160
Apr 22 21:15:21 nanopi kernel: rga_mm: Cannot get src1 channel buffer!
Apr 22 21:15:21 nanopi kernel: rga_mm: failed to get external buffer from job_cmd!
Apr 22 21:15:21 nanopi kernel: rga_mm: failed to map buffer
Apr 22 21:15:21 nanopi kernel: rga_job: rga_job_commit: failed to map job info
Apr 22 21:15:21 nanopi kernel: rga_job: request[1] task[0] job_commit failed.
Apr 22 21:15:21 nanopi kernel: rga_job: rga request commit failed!
Apr 22 21:15:21 nanopi kernel: rga: request[1] submit failed!

I need to transcode 4K30 HEVC files (bitrate 100-150MBps) to:

RGA can only help with the first, or can also help with reducing the bitrate?

How could I best use hw acceleration on RK3568B2 to reach these above goals?

Thank you!

jjm2473 commented 1 year ago

Use libx264 param to control bitrate, it's supported.

I perfer to use '-q:v 80'.

jjm2473 commented 1 year ago

Why don't you check my wiki? https://github.com/jjm2473/ffmpeg-rk/wiki/%E7%BC%96%E8%A7%A3%E7%A0%81

danergo commented 1 year ago

Hi @jjm2473: I did check your wiki, thank you.

However with "q:v 80" RK3568 can't reach above 0.7x speed (which is far from realtime), can I do anything to reach at least 1x speed?

Here is my log:

$ 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
danergo commented 1 year ago

See, at the end: "speed=0.789x". I wish it to have at least 1x.

jjm2473 commented 1 year ago

Fuck! You don't know reducing resolution? RR3568 only supports 1080p@30fps, did you check datasheet? Why you have so many stupid quistions?