本人参考您的文章,静态编译了gstreamer.
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git
cd gstreamer
meson --default-library=static -Dgst-full-libraries=app,video -Dgst-plugins-good:ximagesrc=enabled -Dgst-plugins-base:videotestsrc=enabled -Dgst-plugins-good:v4l2=enabled -Dgst-plugins-ugly:x264=enabled -Dgpl=enabled -Dgst-plugins-base:pango=disabled build
只编译选定的:
meson build-gst-full \
--buildtype=release \
--strip \
--default-library=static \
--wrap-mode=forcefallback \
-Dauto_features=disabled \
-Dgst-full-libraries=app,video,player \
-Dbase=enabled \
-Dgood=enabled \
-Dbad=enabled \
-Dgst-plugins-base:typefind=enabled \
-Dgst-plugins-base:app=enabled \
-Dgst-plugins-base:playback=enabled \
-Dgst-plugins-base:volume=enabled \
-Dgst-plugins-bad:videoparsers=enabled \
-Dgst-plugins-good:ximagesrc=enabled \
-Dgst-plugins-base:videotestsrc=enabled \
-Dgst-plugins-good:v4l2=enabled \
-Dgst-plugins-ugly:x264=enabled \
-Dgpl=enabled \
-Dgst-plugins-base:pango=disabled
meson \
--default-library=static \
--wrap-mode=forcefallback \
-Dgst-full-libraries=app,video,player \
-Dbase=enabled \
-Dgood=enabled \
-Dbad=enabled \
-Dgst-plugins-base:typefind=enabled \
-Dgst-plugins-base:app=enabled \
-Dgst-plugins-base:playback=enabled \
-Dgst-plugins-base:volume=enabled \
-Dgst-plugins-bad:videoparsers=enabled \
-Dgst-plugins-good:ximagesrc=enabled \
-Dgst-plugins-base:videotestsrc=enabled \
-Dgst-plugins-good:v4l2=enabled \
-Dgst-plugins-ugly:x264=enabled \
-Dgpl=enabled \
-Dgst-plugins-base:pango=disabled \
_build
说明,后面的几个disabled是因为遇到pango无法编译过去,反正也不用这个。
配置结果如下:
gst-plugins-bad 1.20.6
Plugins : accurip, adpcmdec, adpcmenc, aiff, asfmux, audiobuffersplit, audiofxbad, audiomixmatrix, audiolatency, audiovisualizers, autoconvert, bayer, camerabin,
codecalpha, coloreffects, debugutilsbad, dvbsubenc, dvbsuboverlay, dvdspu, faceoverlay, festival, fieldanalysis, freeverb, frei0r, gaudieffects, gdp,
geometrictransform, id3tag, inter, interlace, ivfparse, ivtc, jp2kdecimator, jpegformat, rfbsrc, midi, mpegpsdemux, mpegpsmux, mpegtsdemux, mpegtsmux,
mxf, netsim, rtponvif, pcapparse, pnm, proxy, legacyrawparse, removesilence, rist, rtmp2, rtpmanagerbad, sdpelem, segmentclip, siren, smooth, speed,
subenc, switchbin, timecode, transcode, videofiltersbad, videoframe_audiolevel, videoparsersbad, videosignal, vmnc, y4mdec, decklink, dvb, fbdevsink,
ipcpipeline, kms, nvcodec, shm, avtp, dash, fdkaac, hls, iqa, microdns, openjpeg, opusparse, sctp, smoothstreaming
(A)GPL license allowed: True
gst-plugins-base 1.20.6
GL api : gl
GL platform: glx
GL winsys : x11
Plugins : adder, app, audioconvert, audiomixer, audiorate, audioresample, audiotestsrc, compositor, encoding, gio, overlaycomposition, pbtypes, playback, rawparse, subparse,
tcp, typefindfunctions, videoconvert, videorate, videoscale, videotestsrc, volume, opengl, ogg, opus, vorbis, ximagesink, xvimagesink
gst-plugins-good 1.20.6
Plugins: alpha, alphacolor, apetag, audiofx, audioparsers, auparse, autodetect, avi, cutter, navigationtest, debug, deinterlace, dtmf, effectv, equalizer, flv, flxdec, goom,
goom2k1, icydemux, id3demux, imagefreeze, interleave, isomp4, alaw, mulaw, level, matroska, monoscope, multifile, multipart, replaygain, rtp, rtpmanager, rtsp,
shapewipe, smpte, spectrum, udp, videobox, videocrop, videofilter, videomixer, wavenc, wavparse, y4menc, ossaudio, oss4, video4linux2, ximagesrc, jpeg, lame, dv, png
gst-plugins-ugly 1.20.6
Plugins : asf, dvdlpcmdec, dvdsub, realmedia, xingmux, x264
(A)GPL license allowed: True
gstreamer 1.20.6
Plugins: coreelements, coretracers
orc 0.4.33
Backends
SSE : YES
MMX : YES
NEON : YES
MIPS : YES
c64x : YES
Altivec : YES
Build options
Tools : YES
Tests : YES
Examples : YES
Benchmarks : YES
Documentation : NO disabled
Orc-test library: YES
gstreamer-full 1.20.6
Build options
gstreamer-full : YES
Subprojects
cairo : NO Subproject exists but has no meson.build file
gl-headers : YES
gst-devtools : YES 1 warnings
gst-editing-services : YES
gst-examples : NO Subproject "subprojects/libsoup" required but not found.
gst-integration-testsuites : YES
gst-libav : YES
gst-omx : NO Feature 'omx' disabled
gst-plugins-bad : YES 1 warnings
gst-plugins-base : YES 1 warnings
gst-plugins-good : YES 1 warnings
gst-plugins-rs : NO Feature 'rs' disabled
gst-plugins-ugly : YES
gst-python : NO Subproject "subprojects/pygobject" required but not found.
gst-rtsp-server : YES
gstreamer : YES 1 warnings
gstreamer-sharp : NO Feature 'sharp' disabled
gstreamer-vaapi : NO Feature 'vaapi' disabled
libnice : NO Problem encountered: Either GnuTLS or OpenSSL is required as crypto library, but neither was found
libpsl : YES
libsoup : NO Assert failed: libsoup requires glib-networking for TLS support
libsoup3 : NO Neither a subproject directory nor a libsoup3.wrap file was found.
openh264 : NO Program 'nasm nasm.exe' not found or not executable
openssl : NO Neither a subproject directory nor a openssl.wrap file was found.
orc : YES
pygobject : NO Dependency 'glib-2.0' is required but not found.
sqlite3 : YES
tinyalsa : NO Neither a subproject directory nor a tinyalsa.wrap file was found.
User defined options
default_library : static
gpl : enabled
gst-full-libraries : app,video
gst-plugins-base:pango : disabled
gst-plugins-base:videotestsrc: enabled
gst-plugins-good:v4l2 : enabled
gst-plugins-good:ximagesrc : enabled
gst-plugins-ugly:x264 : enabled
Found ninja-1.11.1.git.kitware.jobserver-1 at /usr/local/bin/ninja
ninja -C build
编译后,有 libgstreamer-full-1.0.a libgstreamer-full-1.0.so ,可是gst-inspect-1.0怎么显示只有1个plugin,我用的ubuntu的docker镜像环境编译的。
# ls
GstDocumentedSubprojects build.ninja gstinitstaticplugins.c libgstreamer-full-1.0.a.p libgstreamer-full-1.0.so.p meson-logs meson-uninstalled
GstPluginsPath.json compile_commands.json libgstreamer-full-1.0.a libgstreamer-full-1.0.so meson-info meson-private subprojects
# pwd
/root/gstreamer2/build
# gst-inspect-1.0
staticelements: bin: Generic bin
staticelements: pipeline: Pipeline object
Total count: 1 plugin, 2 features
我重新用ubuntu20.04非docker容器进行编译。成功找到了plugins:
……
vorbis: vorbisdec: Vorbis audio decoder
vorbis: vorbisenc: Vorbis audio encoder
vorbis: vorbisparse: VorbisParse
vorbis: vorbistag: VorbisTag
wavenc: wavenc: WAV audio muxer
wavparse: wavparse: WAV audio demuxer
waylandsink: waylandsink: wayland video sink
webrtc: webrtcbin: WebRTC Bin
x264: x264enc: x264 H.264 Encoder
ximagesink: ximagesink: Video sink
ximagesrc: ximagesrc: Ximage video source
xingmux: xingmux: MP3 Xing muxer
xvimagesink: xvimagesink: Video sink
y4mdec: y4mdec: YUV4MPEG demuxer/decoder
y4menc: y4menc: YUV4MPEG video encoder
Total count: 198 plugins, 1459 features
ninja -C build install
pkg-config可以找到头文件库文件:
pkg-config --cflags gstreamer-1.0 gstreamer-app-1.0
-DGST_STATIC_COMPILATION -pthread -DPCRE2_STATIC -pthread -I/usr/local/include/gstreamer-1.0 -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include
静态编译我的程序(我程序使用pkg-config引入包含文件和库文件)然后运行,出现这个:
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_element_get_bus: assertion 'GST_IS_ELEMENT (element)' failed
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_bus_add_watch_full: assertion 'GST_IS_BUS (bus)' failed
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_object_unref: assertion 'object != NULL' failed
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_bin_get_by_name: assertion 'GST_IS_BIN (bin)' failed
(myapp:2046364): GLib-GObject-CRITICAL **: 14:44:33.323: g_object_set: assertion 'G_IS_OBJECT (object)' failed
(myapp:2046364): GLib-GObject-WARNING **: 14:44:33.323: invalid (NULL) pointer instance
(myapp:2046364): GLib-GObject-CRITICAL **: 14:44:33.323: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_object_unref: assertion 'object != NULL' failed
(myapp:2046364): GStreamer-CRITICAL **: 14:44:33.323: gst_element_set_state: assertion 'GST_IS_ELEMENT (element)' failed
GST_DEGBUG=*:5
完整调试信息如下:
0:00:00.000063436 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:591:init_pre: Initializing GStreamer Core Library version 1.20.6
0:00:00.000075460 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:592:init_pre: Using library installed in /usr/local/lib/x86_64-linux-gnu
0:00:00.000081354 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:610:init_pre: Linux leon.local 5.15.0-60-generic #66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023 x86_64
0:00:00.000141266 2049923 0x7f6ecc004d60 DEBUG GST_MEMORY gstallocator.c:612:_priv_gst_allocator_initialize: memory alignment: 7
0:00:00.000177166 2049923 0x7f6ecc004d60 DEBUG GST_MEMORY gstallocator.c:589:gst_allocator_sysmem_init: init allocator 0x7f6eac00c810
0:00:00.000185587 2049923 0x7f6ecc004d60 DEBUG GST_MEMORY gstallocator.c:230:gst_allocator_register: registering allocator 0x7f6eac00c810 with name "SystemMemory"
0:00:00.000216076 2049923 0x7f6ecc004d60 INFO GST_INIT gstmessage.c:129:_priv_gst_message_initialize: init messages
0:00:00.000266374 2049923 0x7f6ecc004d60 DEBUG GST_ELEMENT_PADS gstelement.c:317:gst_element_base_class_init: type GstElement : factory (nil)
0:00:00.000286912 2049923 0x7f6ecc004d60 DEBUG GST_ELEMENT_PADS gstelement.c:317:gst_element_base_class_init: type GstBin : factory (nil)
0:00:00.000408799 2049923 0x7f6ecc004d60 INFO GST_INIT gstcontext.c:86:_priv_gst_context_initialize: init contexts
0:00:00.000476915 2049923 0x7f6ecc004d60 INFO GST_PLUGIN_LOADING gstplugin.c:324:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.000500967 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:592:gst_registry_add_feature:<registry0> adding feature 0x7f6eac025820 (bin)
0:00:00.000504246 2049923 0x7f6ecc004d60 DEBUG GST_REFCOUNTING gstobject.c:708:gst_object_set_parent:<bin> set parent (ref and sink)
0:00:00.000511366 2049923 0x7f6ecc004d60 DEBUG GST_ELEMENT_PADS gstelement.c:317:gst_element_base_class_init: type GstPipeline : factory 0x7f6eac025900
0:00:00.000519916 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:592:gst_registry_add_feature:<registry0> adding feature 0x7f6eac025900 (pipeline)
0:00:00.000522508 2049923 0x7f6ecc004d60 DEBUG GST_REFCOUNTING gstobject.c:708:gst_object_set_parent:<pipeline> set parent (ref and sink)
0:00:00.000525700 2049923 0x7f6ecc004d60 INFO GST_PLUGIN_LOADING gstplugin.c:232:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.000528805 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:476:gst_registry_add_plugin:<registry0> adding plugin 0x7f6eac024050 for filename "(NULL)"
0:00:00.000531854 2049923 0x7f6ecc004d60 INFO GST_PLUGIN_LOADING gstplugin.c:234:gst_plugin_register_static: added static plugin "staticelements", result: 1
0:00:00.000548968 2049923 0x7f6ecc004d60 INFO GST_REGISTRY gstregistry.c:1826:ensure_current_registry: reading registry cache: /home/leon/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.000569283 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistrybinary.c:626:priv_gst_registry_binary_read_cache: File data at address 0x7f6ed0702000
0:00:00.000572216 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistrybinary.c:535:gst_registry_binary_check_magic: Reading/casting for GstBinaryRegistryMagic at address 0x7f6ed0702000
0:00:00.000579248 2049923 0x7f6ecc004d60 WARN GST_REGISTRY gstregistrybinary.c:551:gst_registry_binary_check_magic: Binary registry magic version is different : 1.3.0 != 1.12.0
0:00:00.000589700 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1854:ensure_current_registry: Updating registry cache
0:00:00.000592234 2049923 0x7f6ecc004d60 INFO GST_REGISTRY gstregistry.c:1693:scan_and_update_registry: Validating plugins from registry cache: /home/leon/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.000594772 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1703:scan_and_update_registry: scanning paths added via --gst-plugin-path
0:00:00.000597449 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1726:scan_and_update_registry: GST_PLUGIN_PATH not set
0:00:00.000599667 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1738:scan_and_update_registry: GST_PLUGIN_SYSTEM_PATH not set
0:00:00.000602842 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1745:scan_and_update_registry: scanning home plugins /home/leon/.local/share/gstreamer-1.0/plugins
0:00:00.000605677 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1411:gst_registry_scan_path_internal:<registry0> scanning path /home/leon/.local/share/gstreamer-1.0/plugins
0:00:00.000634078 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1414:gst_registry_scan_path_internal:<registry0> registry changed in path /home/leon/.local/share/gstreamer-1.0/plugins: 0
0:00:00.000636796 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1761:scan_and_update_registry: using plugin dir /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0
0:00:00.000639288 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1411:gst_registry_scan_path_internal:<registry0> scanning path /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0
0:00:00.000643213 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1414:gst_registry_scan_path_internal:<registry0> registry changed in path /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0: 0
0:00:00.000645586 2049923 0x7f6ecc004d60 DEBUG GST_REGISTRY gstregistry.c:1640:gst_registry_remove_cache_plugins:<registry0> removing cached plugins
0:00:00.000649054 2049923 0x7f6ecc004d60 INFO GST_REGISTRY gstregistry.c:1785:scan_and_update_registry: Registry cache has not changed
0:00:00.000651240 2049923 0x7f6ecc004d60 INFO GST_REGISTRY gstregistry.c:1861:ensure_current_registry: registry reading and updating done
0:00:00.000668973 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:826:init_post: GLib runtime version: 2.74.5
0:00:00.000671986 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:828:init_post: GLib headers version: 2.74.5
0:00:00.000674147 2049923 0x7f6ecc004d60 INFO GST_INIT gst.c:830:init_post: initialized GStreamer successfully
0:00:00.000676690 2049923 0x7f6ecc004d60 DEBUG default gsttracerutils.c:77:_priv_gst_tracing_init: Initializing GstTracer
0:00:00.000684205 2049923 0x7f6ecc004d60 INFO GST_PIPELINE gstparse.c:344:gst_parse_launch_full: parsing pipeline description 'videotestsrc ! videoconvert ! queue ! video/x-raw,format=I420 ! x264enc speed-preset=ultrafast tune=zerolatency key-int-max=20 ! video/x-h264,stream-format=byte-stream ! appsink name=appsink'
0:00:00.000691383 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:135:priv_gst_parse_yylex: flex: IDENTIFIER: videotestsrc
0:00:00.000696067 2049923 0x7f6ecc004d60 WARN GST_ELEMENT_FACTORY gstelementfactory.c:701:gst_element_factory_make_with_properties: no such element factory "videotestsrc"!
0:00:00.000699423 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:851:priv_gst_parse_yyparse: no element "videotestsrc"
0:00:00.000702723 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000705592 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:146:priv_gst_parse_yylex: flex: LINK: !
0:00:00.000710302 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000712914 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:135:priv_gst_parse_yylex: flex: IDENTIFIER: videoconvert
0:00:00.000715574 2049923 0x7f6ecc004d60 WARN GST_ELEMENT_FACTORY gstelementfactory.c:701:gst_element_factory_make_with_properties: no such element factory "videoconvert"!
0:00:00.000718075 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:851:priv_gst_parse_yyparse: no element "videoconvert"
0:00:00.000720674 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000723070 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:146:priv_gst_parse_yylex: flex: LINK: !
0:00:00.000726377 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:939:priv_gst_parse_yyparse: link has no source [sink=@(nil)]
0:00:00.000729181 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000731861 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:135:priv_gst_parse_yylex: flex: IDENTIFIER: queue
0:00:00.000734440 2049923 0x7f6ecc004d60 WARN GST_ELEMENT_FACTORY gstelementfactory.c:701:gst_element_factory_make_with_properties: no such element factory "queue"!
0:00:00.000737509 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:851:priv_gst_parse_yyparse: no element "queue"
0:00:00.000740057 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000743740 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:146:priv_gst_parse_yylex: flex: LINK: ! video/x-raw,format=I420 !
0:00:00.000746480 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:939:priv_gst_parse_yyparse: link has no source [sink=@(nil)]
0:00:00.000750571 2049923 0x7f6ecc004d60 DEBUG structure gststructure.c:2258:gst_structure_parse_field: trying field name 'format'
0:00:00.000758659 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000761585 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:135:priv_gst_parse_yylex: flex: IDENTIFIER: x264enc
0:00:00.000764137 2049923 0x7f6ecc004d60 WARN GST_ELEMENT_FACTORY gstelementfactory.c:701:gst_element_factory_make_with_properties: no such element factory "x264enc"!
0:00:00.000766710 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:851:priv_gst_parse_yyparse: no element "x264enc"
0:00:00.000769135 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000771864 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:93:priv_gst_parse_yylex: flex: ASSIGNMENT: speed-preset=ultrafast
0:00:00.000774653 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000777103 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:93:priv_gst_parse_yylex: flex: ASSIGNMENT: tune=zerolatency
0:00:00.000779763 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000782259 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:93:priv_gst_parse_yylex: flex: ASSIGNMENT: key-int-max=20
0:00:00.000784801 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000787576 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:146:priv_gst_parse_yylex: flex: LINK: ! video/x-h264,stream-format=byte-stream !
0:00:00.000790507 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:939:priv_gst_parse_yyparse: link has no source [sink=@(nil)]
0:00:00.000794246 2049923 0x7f6ecc004d60 DEBUG structure gststructure.c:2258:gst_structure_parse_field: trying field name 'stream-format'
0:00:00.000797941 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000800412 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:135:priv_gst_parse_yylex: flex: IDENTIFIER: appsink
0:00:00.000803176 2049923 0x7f6ecc004d60 WARN GST_ELEMENT_FACTORY gstelementfactory.c:701:gst_element_factory_make_with_properties: no such element factory "appsink"!
0:00:00.000805505 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:851:priv_gst_parse_yyparse: no element "appsink"
0:00:00.000807847 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:181:priv_gst_parse_yylex: flex: SPACE: [ ]
0:00:00.000810845 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE parse.l:93:priv_gst_parse_yylex: flex: ASSIGNMENT: name=appsink
0:00:00.000813644 2049923 0x7f6ecc004d60 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:939:priv_gst_parse_yyparse: link has no source [sink=@(nil)]
0:00:00.000817529 2049923 0x7f6ecc004d60 DEBUG GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:1226:priv_gst_parse_launch: got 0 elements and 0 links
这个静态编译的程序在其他环境运行的。按说静态编译的是无需再动态加载plugin这些的吧。
为什么还是会出现找不到factory,elment的情况呢?
难道如官网所说,需要“合并打包“,难道静态编译的程序也需要“合并打包”和程序一起?如果是,那该合并打包和使用的呢?我需要把程序发给别人,别人无需安装gstreamer 环境就能直接运行。
实在搞不定,特此虔诚请教。
估计需要用静态的代码:
https://gitlab.freedesktop.org/gstreamer/gstreamer/#static-build
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/scripts/generate_init_static_plugins.py
GST_PLUGIN_STATIC_DECLARE(videotestsrc);
void
gst_init_static_plugins (void)
{
static gsize initialization_value = 0;
if (g_once_init_enter (&initialization_value)) {
GST_PLUGIN_STATIC_REGISTER(videotestsrc);
g_once_init_leave (&initialization_value, 1);
}
}
gst_plugin_register_static
Dynamically loaded plugins contain a structure that’s defined using GST_PLUGIN_DEFINE (). This structure is loaded when the plugin is loaded by the GStreamer core. The structure contains an initialization function (usually called plugin_init) that will be called right after that. It’s purpose is to register the elements provided by the plugin with the GStreamer framework. If you want to embed elements directly in your application, the only thing you need to do is to replace GST_PLUGIN_DEFINE () with a call to gst_plugin_register_static (). As soon as you call gst_plugin_register_static (), the elements will from then on be available like any other element, without them having to be dynamically loadable libraries. In the example below, you would be able to call gst_element_factory_make (“my-element-name”, “some-name”) to create an instance of the element.
https://gstreamer.freedesktop.org/documentation/application-development/appendix/compiling.html?gi-language=c#embedding-static-elements-in-your-application
在这个页面搜索,可以找到一些内容:
https://gstreamer.freedesktop.org/documentation/tutorials/index.html?gi-language=c
https://doc.qt.io/qt-5/platform-notes-gstreamer-on-android.html
最清楚的表达:
Application
Qt Multimedia does not contain any plugins and all needed plugins must be included and registered in applications manually by GST_PLUGIN_STATIC_DECLARE and GST_PLUGIN_STATIC_REGISTER after gst_init().
Please refer to the official manual on how to statically link plugins to an application.
https://gstreamer.freedesktop.org/documentation/gstreamer/gstplugin.html?gi-language=c#GST_PLUGIN_STATIC_REGISTER
https://stackoverflow.com/questions/21390989/load-statically-linked-gstreamer-plugin
3
I made an app in which all plugins are compiled inside the app (so it is self-containing)… Maybe this is another option for you, or do you really need to link to the library?
I got my usual code (plugin.c and plugin.h) that I used to compile the plugins in a shared library. I add an extra wrapper header that containts static registration code
static gboolean myplugin_init(GstPlugin * plugin)
{
gboolean ret;
gst_controller_init(NULL, NULL);
GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
GST_DEBUG_CATEGORY_INIT(gst_myplugin_debug, “myplugin”, 0, “description”);
ret = gst_element_register(plugin, “myplugin”, GST_RANK_NONE, GST_TYPE_MECIMOTION);
return ret;
}
void gstmyplugins_register_static()
{
gst_plugin_register_static(
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
“myplugin”,
“description”,
myplugin_init,
“0.0.1”,
“LGPL”,
“myplugins”,
“GStreamer”,
“http://gstreamer.net/”);
gst_plugin_register_static(
…
}
then inside the code for my app i call this registration:
gstmyplugins_register_static();
then continue with
gst_element_factory_make(“myplugin”, NULL);
hope this helps.
Share
Improve this answer
Thanks a lot for this great help.
I successfully compiled and built the gstreamer.
I build the Helloword application with these instructions:
gcc basic-tutorial-1.c -o basic-tutorial-1 pkg-config --cflags --libs gstreamer-1.0
gcc basic-tutorial-1.c -o basic-tutorial-1 pkg-config --cflags --libs gstreamer-1.0 --static
However, when I try to run the binary application, it shows the following error:
0:00:00.012510410 119 0xc4bf00 ERROR GST_PIPELINE subprojects/gstreamer/gst/parse/grammar.y:850:priv_gst_parse_yyparse: no element “playbin”
Reply to this comment
XavierClaessens:
Sep 20, 2022 at 04:44 PM
Hi,
You should link your application against gstreamer-full-1.0. gstreamer-1.0 is only the core library with not plugins.
Reply to this comment