No such element or plugin 'v4l2h264enc'

4.5k Views Asked by At

I'm trying to use GStreamer from docker container, built using this Dockerfile.

The installation worked ok and I'm able to run GStreamer. However, I'm not able to use the element v4l2h264enc with the error that does not exist. When I run gst-inspect I get:

root@95e1ff54cca5:~# gst-inspect-1.0 v4l2h264enc
No such element or plugin 'v4l2h264enc'

But v4l2src works fine:

root@95e1ff54cca5:~# gst-inspect-1.0 v4l2src
Factory Details:
  Rank                     primary (256)
  Long-name                Video (video4linux2) Source
  Klass                    Source/Video
  Description              Reads frames from a Video4Linux2 device
  Author                   Edgard Lima <[email protected]>, Stefan Kost <[email protected]>

Plugin Details:
  Name                     video4linux2
  Description              elements for Video 4 Linux
  Filename                 /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstvideo4linux2.so
  Version                  1.18.0
  License                  LGPL
  Source module            gst-plugins-good
  Source release date      2020-09-08
  Binary package           GStreamer Good Plug-ins source release
  Origin URL               Unknown package origin

I have checked in the build folder of gst-plugins-good and I think that v4l2h265enc library was compiled (there's a file named gstv4l2h265enc.c.o). I tried to add the folder where the file is to LD_LIBRARY_PATH and GST_PLUGIN_PATH but it didn't work.

2

There are 2 best solutions below

3
On

I had the same problem with on a raspberrypi 4 with gstreamer and solved it by enabling the kernel side support (often referenced as "v4l2m2m").

You can check it is activated because you get new /dev/video character device files in addition to /dev/video0. (for me it's 3 new files /dev/video[10,11,12]).

Check that the kernel module is loaded or load it with:

modprobe bcm2835-codec

Then gst-inspect-1.0 video4linux2 should show you the elements you are looking for, such as v4l2h264dec, v4l2h264enc, v4l2vp8dec, .... (sometimes gst-inspect-1.0 does not really retry but relies on a cache which might not reflect recent changes: removing the cache can be helpful. In my install I do rm ~/.cache/gstreamer-1.0/registry.armv8-a.bin)

1
On

I had the same error while running gstreamer on Ubuntu within my laptop. As I understand, v4l2h264enc is for raspberrypi and there were no v4l2h264enc on my laptop. So my solution was - to find analog. x264enc solved my issue.

Here's my original command (for running within raspberrypi):

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg , width=640, height=480 , framerate=15/1 ! jpegdec ! videoconvert ! video/x-raw , colorimetry=bt601 ! v4l2h264enc extra-controls="encode,video_bitrate=368640,video_bitrate_mode=1,h264_level=10,h264_profile=0;" ! 'video/x-h264,profile=high,level=(string)3.2' ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=8004 audiotestsrc wave=4 ! audioconvert ! audioresample ! audio/x-raw,channels=1,rate=16000 ! opusenc bitrate=20000 ! rtpopuspay pt=97 ! udpsink host=127.0.0.1 port=8005

And here's command for laptop:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg , width=640, height=480 , framerate=15/1 ! jpegdec ! videoconvert ! video/x-raw , colorimetry=bt601 ! x264enc bitrate=368640 tune=zerolatency ! 'video/x-h264,profile=high,level=(string)3.2' ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=8004 audiotestsrc wave=4 ! audioconvert ! audioresample ! audio/x-raw,channels=1,rate=16000 ! opusenc bitrate=20000 ! rtpopuspay pt=97 ! udpsink host=127.0.0.1 port=8005

So, the difference is just within these parts:

v4l2h264enc extra-controls="encode,video_bitrate=368640,video_bitrate_mode=1,h264_level=10,h264_profile=0;" 

turned into

x264enc bitrate=368640 tune=zerolatency

I believe this issue differs from author's question but may be helpful to someone.


Another possible solution

is to try installing all necessary packages. Here I described what I was issuing with. I managed to get x264enc work after installing ugly package:

sudo apt install -y gstreamer1.0-plugins-ugly

So, I believe the soultion is to try install all this packages one after another:

sudo apt install -y gstreamer1.0-tools
sudo apt install -y gstreamer1.0-libav
sudo apt install -y gstreamer1.0-plugins-base
sudo apt install -y gstreamer1.0-plugins-good
sudo apt install -y gstreamer1.0-plugins-bad
sudo apt install -y gstreamer1.0-plugins-ugly