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

Double free #8

Closed danergo closed 1 year ago

danergo commented 1 year ago
$ 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 to lower resolution (1080p) based on your wiki. But it seems there is double free and aborts.

Is this stupid?

Originally posted by @danergo in https://github.com/jjm2473/ffmpeg-rk/issues/6#issuecomment-1518710873

jjm2473 commented 1 year ago

There is so many errors before 'double free'. Try delete /dev/ion.

jjm2473 commented 1 year ago

Did you check /dev/dri exists?

jjm2473 commented 1 year ago

If you are using RGA3 (for example RK3588), there is a bug https://github.com/JeffyCN/mirrors/issues/11