ubuntu下 gstreamer 的配置及播放音视频例子(已经验证)
官方网址: http://gstreamer.freedesktop.org Gstreamer安装: 使用sudo apt-get install 安装 sudo apt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-tools gstreamer0.10-doc 安装了如下的gst的插件: gstreamer0.10-tools gstreamer0.10-x gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg gstreamer0.10-alsa gstreamer0.10-schroedinger gstreamer0.10-pulseaudio 有可能需要安装的软件: sudo apt-get install bison sudo apt-get install flex sudo apt-get install zlib1g mad解码插件 apt-get install libmad0-dev apt-get install gstreamer0.10-plugins-ugly Initializing GStreamer
[cpp]
view plain
copy
copy #include<gst/gst.h>
编译运行 gcc-Walltest2.c-otest2 $(pkg-config--cflags--libsgstreamer-0.10) 编译时借助了pkg-config ./test2 ./abc.mp3 使用命令的方式,一样的效果 #gst-launch-0.10 filesrc location=/aaron/gstreamer/test/abc.mp3 ! mad ! autoaudiosink 播放视频:
Ubuntu 12.04gst-launch-0.10 filesrc location=/tmp/video_stream_pipe ! decodebin ! ffmpegcolorspace ! videoscale ! ximagesink sync=false Ubuntu 13.10gst-launch-1.0 filesrc location=/tmp/video_stream_pipe ! decodebin ! videoconvert ! xvimagesink sync=false gst-launch-1.0 filesrc location=/tmp/video_stream_pipe ! decodebin ! videoconvert ! ximagesink sync=false 以下摘至:http://linux.die.net/man/1/gst-launch-0.10
gst-launch-0.10(1) - Linux man pageName
gst-launch - build and run a GStreamer pipeline Synopsisgst-launch[OPTION...]PIPELINE-DESCRIPTION Descriptiongst-launchis a tool that builds and runs basicGStreamerpipelines. In simple form,a PIPELINE-DESCRIPTION is a list of elements separated by exclamation marks (!). Properties may be appended to elements,in the formproperty=value. For a complete description of possible PIPELINE-DESCRIPTIONS see the sectionpipeline descriptionbelow or consult the GStreamer documentation. Please note thatgst-launchis primarily a debugging tool for developers and users. You should not build applications on top of it. For applications,use the gst_parse_launch() function of the GStreamer API as an easy way to construct pipelines from pipeline descriptions. Optionsgst-launchaccepts the following options:
Gstreamer Optionsgst-launchalso accepts the following options that are common to all GStreamer applications:
Pipeline DescriptionA pipeline consistselementsandlinks.Elementscan be put intobinsof different sorts.Elements,linksandbinscan be specified in a pipeline description in any order. Elements ELEMENTTYPE[PROPERTY1 ...] Creates an element of type ELEMENTTYPE and sets the PROPERTIES. Properties PROPERTY=VALUE ... Sets the property to the specified value. You can usegst-inspect(1) to find out about properties and allowed values of different elements. Bins [BINTYPE.]([PROPERTY1 ...]PIPELINE-DESCRIPTION ) Specifies that a bin of type BINTYPE is created and the given properties are set. Every element between the braces is put into the bin. Please note the dot that has to be used after the BINTYPE. You will almost never need this functionality,it is only really useful for applications using the gst_launch_parse() API with 'bin' as bintype. That way it is possible to build partial pipelines instead of a full-fledged top-level pipeline. Links [[SRCELEMENT].[PAD1,...]]![[SINKELEMENT].[PAD1,...]] [[SRCELEMENT].[PAD1,...]]! CAPS ![[SINKELEMENT].[PAD1,...]] Links the element with name SRCELEMENT to the element with name SINKELEMENT,using the caps specified in CAPS as a filter. Names can be set on elements with the name property. If the name is omitted,the element that was specified directly in front of or after the link is used. This works across bins. If a padname is given,the link is done with these pads. If no pad names are given all possibilities are tried and a matching pad is used. If multiple padnames are given,both sides must have the same number of pads specified and multiple links are done in the given order. Caps MIMETYPE[,PROPERTY[,PROPERTY ...]]] [; CAPS[; CAPS ...]] Creates a capability with the given mimetype and optionally with given properties. The mimetype can be escaped using " or '. If you want to chain caps,you can add more caps in the same format afterwards. NAME=[(TYPE)]VALUE Sets the requested property in capabilities. The name is an alphanumeric value and the type can have the following case-insensitive values: Pipeline Control A pipeline can be controlled by signals. SIGUSR2 will stop the pipeline (GST_STATE_NULL); SIGUSR1 will put it back to play (GST_STATE_PLAYING). By default,the pipeline will start in the playing state. Pipeline ExamplesThe examples below assume that you have the correct plug-ins available. In general,"osssink" can be substituted with another audio output plug-in such as "esdsink","alsasink","osxaudiosink",or "artsdsink". Likewise,"xvimagesink" can be substituted with "ximagesink","sdlvideosink","osxvideosink",or "aasink". Keep in mind though that different sinks might accept different formats and even the same sink might accept different formats on different machines,so you might need to add converter elements like audioconvert and audioresample (for audio) or ffmpegcolorspace (for video) in front of the sink to make things work. Audio playback gst-launch filesrc location=music.mp3 ! mad ! audioconvert ! audioresample ! osssink gst-launch filesrc location=music.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioresample ! osssink gst-launch gnomevfssrc location=music.mp3 ! mad ! osssink gst-launch gnomevfssrc location=smb://computer/music.mp3 ! mad ! audioconvert ! audioresample ! osssink Format conversion gst-launch filesrc location=music.mp3 ! mad ! audioconvert ! vorbisenc ! oggmux ! filesink location=music.ogg gst-launch filesrc location=music.mp3 ! mad ! audioconvert ! flacenc ! filesink location=test.flac Other gst-launch filesrc location=music.wav ! wavparse ! audioconvert ! audioresample ! osssink gst-launch filesrc location=music.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesink location=music.ogg gst-launch cdparanoiasrc mode=continuous ! audioconvert ! lame ! id3v2mux ! filesink location=cd.mp3 gst-launch cdparanoiasrc track=5 ! audioconvert ! lame ! id3v2mux ! filesink location=track5.mp3 Usinggst-inspect(1),it is possible to discover settings like the above for cdparanoiasrc that will tell it to rip the entire cd or only tracks of it. Alternatively,you can use an URI and gst-launch-0.10 will find an element (such as cdparanoia) that supports that protocol for you,e.g.:gst-launch cdda://5 ! lame vbr=new vbr-quality=6 ! filesink location=track5.mp3 gst-launch osssrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=input.ogg Video gst-launch filesrc location=JB_FF9_TheGravityOfLove.mpg ! dvddemux ! mpeg2dec ! xvimagesink gst-launch filesrc location=/flflfj.vob ! dvddemux ! mpeg2dec ! sdlvideosink gst-launch filesrc location=movie.mpg ! dvddemux name=demuxer demuxer. ! queue ! mpeg2dec ! sdlvideosink demuxer. ! queue ! mad ! audioconvert ! audioresample ! osssink gst-launch filesrc location=movie.mpg ! mpegdemux name=demuxer demuxer. ! queue ! mpeg2dec ! ffmpegcolorspace ! sdlvideosink demuxer. ! queue ! mad ! audioconvert ! audioresample ! osssink This example also shows how to refer to specific pads by name if an element (here: textoverlay) has multiple sink or source pads. gst-launch textoverlay name=overlay ! ffmpegcolorspace ! videoscale ! autovideosink filesrc location=movie.avi ! decodebin2 ! ffmpegcolorspace ! overlay.video_sink filesrc location=movie.srt ! subparse ! overlay.text_sink Play an AVI movie with an external text subtitle stream using playbin2 gst-launch playbin2 uri=file:///path/to/movie.avi suburi=file:///path/to/movie.srt Network streaming Stream video using RTP and network elements. gst-launch v4l2src ! video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! ffmpegcolorspace ! ffenc_h263 ! video/x-h263 ! rtph263ppay pt=96 ! udpsink host=192.168.1.1 port=5000 sync=false gst-launch udpsrc port=5000 ! application/x-rtp,clock-rate=90000,payload=96 ! rtph263pdepay queue-delay=0 ! ffdec_h263 ! xvimagesink Diagnostic gst-launch -v fakesrc num-buffers=16 ! fakesink gst-launch audiotestsrc ! audioconvert ! audioresample ! osssink gst-launch videotestsrc ! xvimagesink Automatic linking You can use the decodebin element to automatically select the right elements to get a working pipeline. gst-launch filesrc location=musicfile ! decodebin ! audioconvert ! audioresample ! osssink gst-launch filesrc location=videofile ! decodebin name=decoder decoder. ! queue ! audioconvert ! audioresample ! osssink decoder. ! ffmpegcolorspace ! xvimagesink gst-launch playbin uri=file:///home/joe/foo.avi Filtered connections These examples show you how to use filtered caps. gst-launch videotestsrc ! 'video/x-raw-yuv,format=(fourcc)YUY2;video/x-raw-yuv,format=(fourcc)YV12' ! xvimagesink gst-launch osssrc ! 'audio/x-raw-int,rate=[32000,64000],width=[16,32],depth={16,24,32},signed=(boolean)true' ! wavenc ! filesink location=recording.wav Environment VariablesGST_DEBUG
Files~/.gstreamer-0.10/registry-*.xml
(编辑:台州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |