nyanmisaka / ffmpeg-rockchip

FFmpeg with async and zero-copy Rockchip MPP & RGA support
Other
325 stars 47 forks source link

The problem of Chinese garbled code in drawtext #57

Closed BlackJulySnow closed 2 months ago

BlackJulySnow commented 2 months ago

chip:rk3588 board: orange pi5

root@orangepi5:~# cat /proc/version
Linux version 5.10.160-rockchip-rk3588 (root@orangepi5) (aarch64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1.1.8 SMP Mon Nov 13 11:22:15 CST 2023

Sometimes some Chinese can be partly displayed, and sometimes Chinese can not be displayed.

root@orangepi5:~# ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -i 1.mp4 -vf scale_rkrga=w=1920:h=1080,hwdownload,format=nv12,drawtext=text='中文':fontfile=msyh.ttc:fontsize=200 -c:v h264_rkmpp -y -t 10  2.mp4
ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga --enable-filter=drawtext --enable-libharfbuzz --enable-libfreetype --enable-libfontconfig --enable-libfreetype --enable-libfribidi
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mpeg, from '1.mp4':
  Duration: 00:02:59.85, start: 6095.275000, bitrate: 2593 kb/s
  Stream #0:0[0x1e0]: Video: hevc (Main), yuvj420p(pc, bt709), 2560x1440, 15 fps, 25 tbr, 90k tbn
  Stream #0:1[0x1c0]: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_rkmpp) -> h264 (h264_rkmpp))
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0x5577682660] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
rga_api version 1.10.0_[8]
Output #0, mp4, to '2.mp4':
  Metadata:
    encoder         : Lavf60.16.100
  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), nv12(pc, bt709, progressive), 1920x1080, q=2-31, 2000 kb/s, 25 fps, 12800 tbn
    Metadata:
      encoder         : Lavc60.31.102 h264_rkmpp
  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s
    Metadata:
      encoder         : Lavc60.31.102 aac
[out#0/mp4 @ 0x55775c7590] video:2433kB audio:52kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.149914%
frame=  250 fps=0.0 q=-0.0 Lsize=    2490kB time=00:00:09.99 bitrate=2041.1kbits/s dup=100 drop=0 speed=12.6x    
[aac @ 0x5577682660] Qavg: 40287.332

image

root@orangepi5:~# ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -i 1.mp4 -vf "scale_rkrga=w=1920:h=1080,hwdownload,format=nv12,drawtext=text='中文字幕测试':fontfile=msyh.ttc:fontsize=200" -c:v h264_rkmpp -y -t 10  3.mp4
ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga --enable-filter=drawtext --enable-libharfbuzz --enable-libfreetype --enable-libfontconfig --enable-libfreetype --enable-libfribidi
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mpeg, from '1.mp4':
  Duration: 00:02:59.85, start: 6095.275000, bitrate: 2593 kb/s
  Stream #0:0[0x1e0]: Video: hevc (Main), yuvj420p(pc, bt709), 2560x1440, 15 fps, 25 tbr, 90k tbn
  Stream #0:1[0x1c0]: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_rkmpp) -> h264 (h264_rkmpp))
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0x55d26df660] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
rga_api version 1.10.0_[8]
Output #0, mp4, to '3.mp4':
  Metadata:
    encoder         : Lavf60.16.100
  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), nv12(pc, bt709, progressive), 1920x1080, q=2-31, 2000 kb/s, 25 fps, 12800 tbn
    Metadata:
      encoder         : Lavc60.31.102 h264_rkmpp
  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s
    Metadata:
      encoder         : Lavc60.31.102 aac
[out#0/mp4 @ 0x55d2624590] video:2427kB audio:52kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.150300%
frame=  250 fps=0.0 q=-0.0 Lsize=    2483kB time=00:00:09.99 bitrate=2035.8kbits/s dup=100 drop=0 speed=11.5x    
[aac @ 0x55d26df660] Qavg: 40287.332

image

nyanmisaka commented 2 months ago

Those squares or tofu simply means the required Chinese fonts are not available in the environment.

Closing because this is not relevant to this ffmpeg fork.