zl程序教程

您现在的位置是:首页 >  工具

当前栏目

Gstreamer学习流水账

学习 gstreamer
2023-09-11 14:15:46 时间

Gstreamer是Linux上的一套多媒体框架,集采集,编码,解码,渲染,滤镜等功能一条龙的媒体解决方案,它的调度能力和扩展能力非常出色,被广泛应用在各种多媒体方案上 ,这里总结一些学习记录和心得,采用编年体,比较自由,到最后肯定会是一篇流水账。

1.查看系统安装了哪些插件

czl@czl-VirtualBox:~/WorkSpace$ gst-inspect-1.0 |grep -i videosink
inter:  intervideosink: Internal video sink
autodetect:  autovideosink: Auto video sink
decklink:  decklinkvideosink: Decklink Video Sink
debugutilsbad:  fpsdisplaysink: Measure and show framerate on videosink
debugutilsbad:  fakevideosink: Fake Video Sink
cluttergst3:  clutterautovideosink: Generic bin

czl@czl-VirtualBox:~/WorkSpace$ gst-inspect-1.0 |grep -i v4l
video4linux2:  v4l2src: Video (video4linux2) Source
video4linux2:  v4l2sink: Video (video4linux2) Sink
video4linux2:  v4l2radio: Radio (video4linux2) Tuner
video4linux2:  v4l2deviceprovider (GstDeviceProviderFactory)
czl@czl-VirtualBox:~/WorkSpace$ 

caozilong@caozilong-Vostro-3268:~/Workspace/camera$ v4l2-ctl --list-devices
Integrated Camera: Integrated C (usb-0000:00:14.0-2):
	/dev/video0
	/dev/video1

caozilong@caozilong-Vostro-3268:~/Workspace/camera$ 

V4L2 plugin注册:

gstv4l2videodec.c启动解码任务:

最终是调用gst-base包中的gst_video_decoder_xxx plugin进行解码的。

V4L2设备打开:


2.videoconvert组件的作用,当不加入videoconvert组件时,以下两个命令会出错:

gst-launch-1.0 filesrc location=./test.mp4  ! decodebin  ! ximagesink
gst-launch-1.0 filesrc location=./test.mp4  ! decodebin  ! xvimagesink
czl@czl-VirtualBox:~/WorkSpace/ffserver$ gst-launch-1.0 filesrc location=./test.mp4  ! decodebin  ! ximagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0: Internal data stream error.
Additional debug info:
qtdemux.c(6073): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
czl@czl-VirtualBox:~/WorkSpace/ffserver$ gst-launch-1.0 filesrc location=./test.mp4  ! decodebin  ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0: Internal data stream error.
Additional debug info:
qtdemux.c(6073): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
czl@czl-VirtualBox:~/WorkSpace/ffserver$ 

但是,加入videoconvert后,命令正确执行:

gst-launch-1.0 filesrc location=./test.mp4  ! decodebin ! videoconvert ! ximagesink
gst-launch-1.0 filesrc location=./test.mp4  ! decodebin ! videoconvert ! xvimagesink

3.gst audio sink test

gst-launch-1.0 audiotestsrc ! pulsesink
czl@czl-RedmiBook-14:~$ gst-inspect-1.0 pulseaudio
Plugin Details:
  Name                     pulseaudio
  Description              PulseAudio plugin library
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstpulseaudio.so
  Version                  1.14.5
  License                  LGPL
  Source module            gst-plugins-good
  Source release date      2019-05-29
  Binary package           GStreamer Good Plugins (Ubuntu)
  Origin URL               https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0

  pulsedeviceprovider: PulseAudio Device Provider
  pulsesrc: PulseAudio Audio Source
  pulsesink: PulseAudio Audio Sink

  3 features:
  +-- 2 elements
  +-- 1 device providers

czl@czl-RedmiBook-14:~$

结束!