jellyfin-ffmpeg icon indicating copy to clipboard operation
jellyfin-ffmpeg copied to clipboard

h264_v4l2m2m acceleration in Raspberry Pi 4 - 64 bits

Open nfj25 opened this issue 4 years ago • 20 comments

Describe the bug h264_v4l2m2m acceleration is broken in Raspberry Pi 4 64 bits. When trying to use it (Exynos V4L2 MFC), ffmpeg returns the error:

[h264_v4l2m2m @ 0x5587de52e0] Encoder requires yuv420p pixel format.

This is due to the fact that jellyfin is forcing this parameter (EncodingHelper.cs):

if (string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
            {
                param += " -pix_fmt nv21";
            }

But testing ffmpeg with: -pix_fmt yuv420p

Worked and in my tests was much faster than using libx264 with the same parameters.

Probably, "Exynos V4L2 MFC" wasn't meant for Raspberry Pi. But as jellyfin/jellyfin#4023 OpenMax doesn't work in 64bits and because the recomended alternative is using h264_v4l2m2m (https://github.com/raspberrypi/Raspberry-Pi-OS-64bit/issues/98) maybe we could try to use this instead. By the way, VAAPI option doesn't seam to be doing anything, it uses the normal libx264.

System (please complete the following information):

  • OS: Raspbian (Arm64)
  • Virtualization: Docker
  • Jellyfin Version: 10.6.4
  • Storage: local

To Reproduce

Doesn't work:

/usr/lib/jellyfin-ffmpeg/ffmpeg -i file:"/data/movies/input.mp4" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_v4l2m2m -pix_fmt nv21 -b:v 9990684 -maxrate 9990684 -bufsize 19981368 -level 41 -force_key_frames:0 "expr:gte(t,0+n_forced*3)" -g 72 -keyint_min 72 -sc_threshold 0 -vf "scale=trunc(min(max(iw\,ih*dar)\,1920)/64)*64:trunc(ow/dar/2)*2" -start_at_zero -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 224000 -af "volume=2" -copyts -avoid_negative_ts disabled -start_number 0 output.mp4

Works:

/usr/lib/jellyfin-ffmpeg/ffmpeg -i file:"/data/movies/input.mp4" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_v4l2m2m -pix_fmt yuv420p -b:v 9990684 -maxrate 9990684 -bufsize 19981368 -level 41 -force_key_frames:0 "expr:gte(t,0+n_forced*3)" -g 72 -keyint_min 72 -sc_threshold 0 -vf "scale=trunc(min(max(iw\,ih*dar)\,1920)/64)*64:trunc(ow/dar/2)*2" -start_at_zero -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 224000 -af "volume=2" -copyts -avoid_negative_ts disabled -start_number 0 output.mp4

nfj25 avatar Dec 30 '20 16:12 nfj25