I have a program using gstreamer which I have not compiled for many years. I recently needed to compile it again - and it throws up a problem.
In my program I attempt to use x264enc as part of my pipeline - but when I attempt to build my pipeline, the x264enc element fails.
I have included the ugly plugins on my system.
What should I look at to rectify my problem?
Perhaps you could tell us how it fails, for what kind of pipeline?
I create the pipeline like this.
/* Create gstreamer elements */
pipeline = gst_pipeline_new (âav-recorderâ);
vsource = gst_element_factory_make (âv4l2srcâ, âvid-sourceâ);
queue1a = gst_element_factory_make (âqueueâ, âqueue1aâ);
vidrate = gst_element_factory_make (âvideorateâ, âvidrateâ);
vidscale = gst_element_factory_make (âvideoscaleâ, âvidscaleâ);
vcapsfilter = gst_element_factory_make (âcapsfilterâ, âvid-capsâ);
queue1 = gst_element_factory_make (âqueueâ, âqueue1â);
vidconvert = gst_element_factory_make (âvideoconvertâ,âvidconvertâ);
videnc = gst_element_factory_make (âx264encâ, âvidencâ);
asource = gst_element_factory_make (âalsasrcâ, âalsa-sourceâ);
acapsfilter = gst_element_factory_make (âcapsfilterâ, âaudio-capsâ);
queue2 = gst_element_factory_make (âqueueâ, âqueue2â);
audrate = gst_element_factory_make (âaudiorateâ, âaudrateâ);
queue3 = gst_element_factory_make (âqueueâ, âqueue3â);
lameenc = gst_element_factory_make (âlamemp3encâ, âlameencâ);
mux = gst_element_factory_make (âmp4muxâ, âmp4-muxâ);
sink = gst_element_factory_make (âfilesinkâ, âfile-outputâ);
tee = gst_element_factory_make (âteeâ, âteeâ);
aconv2 = gst_element_factory_make (âaudioconvertâ, âaudio2-convâ);
queue4 = gst_element_factory_make (âqueueâ, âqueue4â);
wavenc = gst_element_factory_make (âwavencâ, âwav-encoderâ);
asink = gst_element_factory_make (âfilesinkâ, âwav-outputâ);
videotee = gst_element_factory_make (âteeâ, âvideoteeâ);
queue5 = gst_element_factory_make (âqueueâ, âqueue5â);
monrate = gst_element_factory_make (âvideorateâ, âmonrateâ);
monscale = gst_element_factory_make (âvideoscaleâ, âmonscaleâ);
moncapsfilter = gst_element_factory_make (âcapsfilterâ, âmon-capsâ);
monconvert = gst_element_factory_make (âvideoconvertâ, âmon-convertâ);
videosink = gst_element_factory_make (âautovideosinkâ, âvideosinkâ);
if (!pipeline || !vsource || !vidrate || !vcapsfilter || !queue1 || !videnc || !asource || !acapsfilter || !queue2 || !audrate || !queue3 || !lameenc || !mux || !sink || !tee || !aconv2 || !queue4 || !wavenc || !asink || !videotee || !queue5 || !monrate || !monscale || !moncapsfilter || !monconvert || !videosink) {
g_printerr (âOne element could not be created. Exiting.\nâ);
return;
}
I modified the code to check each element individually and only âvidencâ failed.
Is there a list of plugins - so that I can select an alternative encoder to x264 for testing purposes? I canât find one.
gst-inspect-1.0
would list the available plugins/elements in your system.
gst-inspect-1.0 your_element
would display various information about that element.
OK. So that showed that I do not have x264enc. That would explain why the gst_element_factory_make did not work.
I thought that x264enc was supposed to be in the ugly plugin. I have gstreamer-plugins-ugly-free installed, so it obviously wasnât there. Has it moved elsewhere?
Not sure, it mainly means that it is not yet working within gstreamer.
The plugin might be installed in your system, though gstreamer might not be aware of it or it might have missing dependencies.
Gstreamer has a cache that may need to be updated. You would just delete it (or move it) and it will be recreated next time you use a gstreamer command.
The cache location depends on your OS (Linux: $HOME/.cache/gstreamer-1.0/
, Windows: $HOME\AppData\Local\Microsoft\Windows\INetCache\gstreamer-1.0
), and name on your platform architecture (such as registry.arch.bin).
Then re-create the cache and show any blacklisted element:
gst-inspect-1.0 -b
You can quickly check if the same happens with:
gst-launch-1.0 videotestsrc ! x264enc ! fakesink
I tried
and it reported that there was no x264enc.
I checked what packages I have installed and it came up with
Installed packages
gstreamer1.i686 1.24.8-1.fc41 fedora
gstreamer1.x86_64 1.24.8-1.fc41 fedora
gstreamer1-devel.x86_64 1.24.8-1.fc41 fedora
gstreamer1-plugin-libav.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugin-openh264.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-bad-free.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-bad-free-libs.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-base.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-good.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-good-gtk.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-good-qt.x86_64 1.24.11-1.fc41 updates
gstreamer1-plugins-ugly-free.x86_64 1.24.11-1.fc41 updates
I noticed that the first three packages were not at the same level as the rest. I did an update, and now they are. However the result is the same. gst-inspect-1.0 -b shows no blacklisted files.
After upgrading, did you try to clear the cache ?
If yes and no blacklisted plugin, didnât then gst-inspect-1.0
show x264enc and the shell command still fails ?
If yes you would have to check the directory where you have gstreamer-plugins-ugly installed, check if there is a lib such as libgstx264.so
. If installed into an unusual path, you may add this path in front of GST_PLUGIN_PATH
environment variable, then recreate the cache and check.
Hello, Iâve never used fedora but x264 is not even listed as a file in that package:
lib64/
gstreamer-1.0/
libgsta52dec.so
libgstasf.so
libgstcdio.so
libgstdvdlpcmdec.so
libgstdvdread.so
libgstdvdsub.so
libgstmpeg2dec.so
libgstrealmedia.so
Compare that to the ugly package for debian where x264enc is listed.
/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstx264.so
There is another software encoder for h264 called openh264enc
, you have the package for that installed already. You might be able to use that instead? Or there might be hardware encoders available on your device.
I originally wrote the program over 10 years ago and at that time, x264enc came with the fedora âsetâ.
I have tried the openh264enc - but the pipeline did not link properly. I havenât determined why as yet.
You may try (assuming that youâve a working local display):
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=I420 ! openh264enc ! h264parse ! queue ! decodebin ! autovideoconvert ! autovideosink
Otherwise just:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=I420 ! openh264enc ! fakesink
If youâre on fedora, you may need to use some rpmfusion packages. Or you can build x264/GStreamer yourself.
OK. I attempted the first option - but it âcould not initialize the supporting libraryâ
an@fedora:~$ gst-launch-1.0 -v videotestsrc ! video/x-raw,format=I420 ! openh264enc ! h264parse ! queue ! decodebin ! autovideoconvert ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter3.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3177): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0: Could not initialise supporting library.
Additional debug info:
../ext/openh264/gstopenh264enc.cpp(764): gst_openh264enc_set_format (): /GstPipeline:pipeline0/GstOpenh264Enc:openh264enc0:
Failed to create OpenH264 encoder.
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind: Stream doesn't contain enough data.
Additional debug info:
../plugins/elements/gsttypefindelement.c(1012): gst_type_find_element_chain_do_typefinding (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind:
Can't typefind stream
ERROR: pipeline doesn't want to preroll.
Freeing pipeline ...