-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
h264_v4l2m2m acceleration in Raspberry Pi 4 - 64 bits #310
Comments
Removing the -pix_fmt argument (or changing it) does make V4L2 work on the Raspberry Pi $ v4l2-ctl --all -d /dev/video10
$ v4l2-ctl --all -d /dev/video11
Actually, the above problem happens when specifying mkv output. It seems to work with an mp4 file extension. Oops. :P Anyway, for now (until this -pix_fmt issue is ironed out), you can still get hardware acceleration on the Pi through OpenMAX (even on a 64-bit OS) by using multiarch to install jellyfin/jellyfin-ffmpeg/dependencies as armhf so they can talk to the /opt/vc libraries. Also, as you say, there is no VAAPI capability on the Pi, despite what the current Jellyfin documentation says. I did see the post on reddit that resulted in it being added to the documentation and I did try myself on Ubuntu Server 20.04.1; it simply does not work, and I cannot find any official mention of vaapi support either. Afaik we got the /dev/dri/renderD128 node because of changes in mesa and the new KMS/DRM graphics driver stack - its presence indicates support for DRI (?) but doesn't guarantee VAAPI. Mesa drivers that implement VAAPI have an extra $driverName_drv_video.so file in /usr/lib/$arch-linux-gnu/dri that we don't have. It may be worth opening a separate issue about that. |
Hello, My /opt/vc libraries for 64bit raspbian dont have the required video libraries. What is "jellyfin/jellyfin-ffmpeg/dependencies"? I cant find it... |
Under normal circumstances I believe you can install them with rpi-update (warning that the latest firmware commit is currently bugged and will ignore your config.txt. Don't run rpi-update right now, or specify the 5.10.6 commit if you do). Alternatively, they are also provided by the libraspberrypi0 package, but this probably won't install them to /opt/vc anymore as it's considered an "old" location. The Ubuntu wiki recommends symlinking /usr and /opt/vc to work around this. (The /opt/vc path for the libraries seems to be hardcoded into the ffmpeg builds, which is what one of the bugs you linked referenced.) If you're on 64 bit raspbian, you'd have to explicitly install the 32 bit version of libraspberrypi0 so that 32 bit binaries can link to them and libopenmaxil.so will be installed. However, none of this matters anyway, because you're using docker. It's the container's responsibility to ensure it has access to the libraries it needs. It can't just use your system's libraries. I had a look at the dockerfile and it does install libraspberrypi0 but whether the libraries in the container are then available at /opt/vc is anyone's guess,
I meant "jellyfin and jellyfin-ffmpeg and their dependencies". If you're using docker the equivalent is installing the armhf docker container. There are enough caveats to this process that it would probably be better to wait for V4L2 support to be fixed in Jellyfin rather than try to get OpenMAX working. |
btdt. +1. |
OpenMax encoder is only available on arm32 since some runtime are missing on arm64. |
Sorry, I'm dumb. I had some permission errors with jellyfin user accessing /dev/vchiq. In my case, by default it was owned by root:root (not root:video) and had crw------ permissions. It works fine once I ironed out my permission errors (with jellyfin user in the video group, I changed owner of /dev/vchiq to root:video and changed permissions to crw-rw---). This can be made to persist by changing udev rules for the device. I was testing at a root shell because I couldn't hang around in /var/log/jellyfin as my own user, so obviously it worked when logged in as root... A couple snippets showing I am running a 64-bit system, OpenMAX acceleration is being used, and the installed libopenmaxil.so and jellyfin-ffmpeg are both 32-bit:
I haven't tested this as I just keep the old /opt/vc folder in my install and vanilla debian doesn't offer the libraspberrypi0 package, but I think this is the symlink you would need to make, it was suggested by the Ubuntu wiki as a result of the move:
You're making a symlink at /opt/vc that points to the directory /usr. This is because then when ffmpeg looks for An alternative "workaround" - if you are okay with only one transcode at a time and you're using a Pi 4, software transcoding can handle most h264 transcodes at roughly 1x speed. I have had good luck doing this with these static builds (get the git master build for arm64). |
Did it eventually work to install librasperrypi0 armhf and make a symlink? |
This comment was marked as outdated.
This comment was marked as outdated.
I believe a lot of RPI users like me and a friend is interested in this being added to jellyfin. So I'm writing here to keep the post alive. Best regards and hope the feature will be added. Darkyere |
Can we maybe get the V4L option made a bit more generic with pixel format broken out as a dropdown option? It looks like that + unchecking 10-bit content would fix most of the issues |
Same playback error for me. However in my case the error only occurs with .avi files. Can anyone confirm? build_version | Linuxserver.io version:- 10.7.7-1-ls134 Build-date:- 2021-10-07T04:33:17+02:00 Webinterface: Logs: |
Raspberry Pi OS Bullseye has ffmpeg 4.3.3 available, maybe V4L2 support is now stable enough for use in Jellyfin? |
The newly developed V4L2 H264/H265 decoders are stable enough in rpi-ffmpeg. But we are still lacking of |
Too bad the hw encoding are at this state on RPI 4 64bits OS. I think it like the only feature that's trully miss. |
ran into this issue with my rpi4 and jellyfin in docker trying to use h264_v4l2m2m
|
It seems that in jellyfin/jellyfin#7291 some progress on this issue has occurred. However, as discussed over there:
After some digging it seems like a patch for V4L2 scaling has been open for almost three years now: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190903010230.96236-21-ffmpeg@tmm1.net/ If I understand it correctly, we thus have all components required to effectuate a full, transferless, in-GPU encoding pipeline, but the loose ends have just not been tied together. I have opened an issue over at rpi-ffmpeg in order to try to get this patch upstreamed (well, or rather, downstreamed, mhm 🤔) a little bit quicker. Hopefully this will once and for all make HWA on a RPI happen 👏 |
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):
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 (raspberrypi/Raspberry-Pi-OS-64bit#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):
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
The text was updated successfully, but these errors were encountered: