-
Notifications
You must be signed in to change notification settings - Fork 5.2k
RPI4 bcm2835-codec: Unable to use v4l2 h264 encoder #3974
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
Comments
I don't have a 5.4 64bit kernel to hand. It works fine on my 32bit 5.10.0-rc5 kernel with GStreamer 1.14.4. Can you check whether it is 5.4 being old, using a 64bit kernel, or GStreamer 1.18 that is the issue please? |
I suspect it might be the 64bit kernel. I've tried with 64bit kernel with 32bit stock raspbian userspace - same fault. |
Thanks for testing. I wonder if it is nothing having called the equivalent of bcm_host_init. I looked into that one a while back and couldn't come up with a sensible answer over what was needed where. There isn't a bcm_host_exit, therefore once something has called _init other things don't care. |
I've also just tried the same with a raspberry 3B+, but on the B+ this fails more spectacularly. vchiq throws |
Just tried a 32bit custom built kernel 42aa6ae Same issue as before
|
Hi, I have got similar problem with gstreamer and v4l2h264enc. I tried aarch64 and armv7l 5.10.16 with same results. But there seems to be difference in gstreamer versions:
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/849#note_811828 Do you have more information for this issue? |
Yes it appears something is broken when using gstreamer >=1.18 . 1.16 also appears to work. |
It looks like this commit changed it (applied from version 17.1) https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/6ce195e9d1139d109b4301812221dc74f986909b In the commit description, there is info about change for profiles and levels advertised by the kernel. Maybe the kernel is not advertising actual state right. I haven't tried it with older kernel 4.x |
Levels and profiles are supported by the encoder as per the V4L2 controls
The encoder does validate the resolution & framerate vs the specified level restrictions when the port is enabled (triggered by STREAMON). If you run Likewise setting /sys/class/video4linux/video11/dev_debug to 0x2f before running GStreamer will dump out a lot of kernel side debug from the V4L2 framework (you may need to filter it by setting to other than 0x2f - it's a bitmask based on the V4L2_DEV_DEBUG_* defines https://elixir.bootlin.com/linux/latest/source/include/media/v4l2-ioctl.h#L596). That may reveal what and why the codec is being configured in a way it objects to. |
056849.731: video_encode:5:RIL: open encoder |
Annoyingly -1073807358 (actually 0xBFFF0002) is just |
I'm looking in dmesg and here it crash
|
The
is on the list of things to look at. As per the comment in the source
So it's a question of working out which buffers and why they haven't been returned. videobuf2 cleans up afterwards anyway, so it can be ignored. |
It's the list of transactions prior to the STREAMON that are of interest to determine how GStreamer is trying to configure the codec. |
i am runing latest Ubuntu Server 20.04
|
There are some errors, mainly -22 and -25
|
Gstreamer parameters issue, not kernel driver.
Set the level more sensibly, eg Level 3 is required for 10Mbit/s. Drop the bitrate via |
Thank you very much! For recording v4l2 camera 1280x720, this pipeline is working for me (if somebody would need to insiper). |
@walmis As the original reporter are you happy to close? |
Yes, thank you for solving this. Hopefully this information will get documented somewhere. |
It seems to not work at higher resolutions and framerates (that are supported by raspivid)?
|
You've edited your comment. The original listed 1640x1232 @ 40fps. Level 4.2 has a limit of 522240 macroblocks/s, whilst level 4 is 245760. https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels Then again the V4L2 codec doesn't allow for levels above 4 at present. I'll sort a PR later (it's only missing case statements). |
Yeah, I had copy-and-pasted the wrong run, but it was always 1640x1232 (explicitly or implied). Glad to know it doesn't involve more than what you described. |
Software-based encoders seem to infer profile/level caps, but v4l2-based encoder requires these to be set for bitrate ref: raspberrypi/linux#3974 (comment)
Software-based encoders seem to infer profile/level caps, but v4l2-based encoder requires these to be set for bitrate ref: raspberrypi/linux#3974 (comment)
just in case anyone else ends up in this rabbit-hole ... being explicit about |
I'm trying to launch this simple pipeline using gstreamer
gst-launch-1.0 videotestsrc ! v4l2h264enc ! fakesink
but it always fails.gstreamer version is 1.18.0
Decoder seems to work.
Kernel is:
Linux ubuntu 5.4.72-v8 #3 SMP PREEMPT Fri Nov 27 10:52:11 EET 2020 aarch64 aarch64 aarch64 GNU/Linux
I've tried current kernel and firmware pair and also from the
next
branch. RPI is setup to boot from network using, rootfs is ext4 over network block device (nbd).Steps I've tried:
config.txt
Full logs:
dmesg.txt
kconfig.txt
Am I missing something? I've googled a lot, but I haven't found any solutions. Any pointers how to debug this?
The text was updated successfully, but these errors were encountered: