Grammar
I am using the gstreamer pipeline to encode an mp4 file for different bitrates. I built a pipeline using code from the gst-streaming server. The pipeline is not working. I can't figure out the syntax of the pipeline here in order to debug it.
gst-launch-1.0 filesrc location=video_test.mp4 name=src ! \
decodebin name=dec queue name=vqueue ! \
videosegmentclip name=vclip ! \
videoconvert ! \
video/x-raw, format=I420 ! \
videocrop top=0 bottom=0 left=0 right=0 ! \
queue ! \
tee name=vtee queue name=aqueue max-size-time=5000000000 max-size-bytes=0 max-size- buffers=0 ! \
audiosegmentclip name=aclip ! \
audioconvert ! \
audio/x-raw, channels=2 ! \
audioresample ! \
audio/x-raw, rate=48000 ! \
voaacenc bitrate=128000 ! \
queue ! \
tee name=atee vtee. ! \
queue ! \
videoscale add-borders=false ! \
video/x-raw,pixel-aspect-ratio=1/1,width=1280,height=720 ! \
x264enc name=venc0 bitrate=2372 tune=zerolatency ! \
queue ! \
mp4mux name=mux0 ! \
watchdog timeout=5000 ! \
filesink name=sink0 location=out0.mp4 atee. ! \
queue ! \
mux0. \
Above is a complete pipeline. The tough part for me in understanding is below
decodebin name=dec queue name=vqueue
Not! in the line above and shouldn't be! between decodemin and queue
tee name=vtee queue name=aqueue... ! audiosegmentclip
There is a tee in the above line called vtee (video teet) but associated with the audio client. How it works?
tee name=atee vtee. ! queue
The line above has a tee named atee followed by vtee. What does this mean? what is the meaning of having a period (.) after an element?
Any links explaining the gstreamer pipeline grammars would be very helpful.
source to share
The general idea you want can be found in this pipeline. The main differences are:
- No Tee needed as it
decodebin
has a variety of gaskets to accommodate different types of media. - First I process the video logically, push it to the multiplexer and then the audio. I find that mixing audio and video elements together in a pipeline makes me hook up logically and it's easier to handle the first and then the other with it.
-
I've removed some items that you could add if you really want to (some settings and queue filters)
gst-launch-1.0 filesrc location=test.mp4 name=src ! decodebin name=dec ! \ queue name=vqueue ! videosegmentclip name=vclip ! videoconvert ! \ video/x-raw, format=I420 ! videocrop top=0 bottom=0 left=0 right=0 ! \ videoscale add-borders=false ! \ video/x-raw,pixel-aspect-ratio=1/1,width=1280,height=720 ! \ x264enc name=venc0 bitrate=2372 tune=zerolatency ! queue ! mux. dec. ! \ audiosegmentclip name=aclip ! audioconvert ! audio/x-raw, channels=2 ! \ audioresample ! audio/x-raw, rate=48000 ! voaacenc bitrate=128000 ! \ queue ! mp4mux name=mux ! watchdog timeout=5000 ! \ filesink name=sink0 location=out0.mp4
source to share
I struggled with the syntax too. The gst-launch-1.0 man page says:
The pipeline consists of elements and links. Items can be bins of all kinds. Items, links and baskets can be listed in the pipeline description in any order.
I was embarrassed thinking about it! (link) is like a bash pipe, and these items are like bash commands that generate and receive data, and so you need to have a list of commands concatenated with !. This is not the case in gstreamer. A pipeline description is a list of items, links, and bins in any order. Here is my attempt at grammar (leaving the bins and caps). Note what *
variable number /
means and means one of the alternatives.
pipeline = pipeline_item*
pipeline_item = element / link
element = NAME property*
property = NAME=VALUE
link = ! / pad ! pad
pad = ELEMENT_NAME. / ELEMENT_NAME.padnames
padnames = NAME / NAME,padnames
Or, to summarize in English:
- NAME is an element
- NAME = VALUE is a property
- NAME. or NAME.PAD is a pad (note the. after both forms).
- ! is a link and can be used like:
- element1! element2
- element1 name = e1 element2 name = e2 e1.! e2.
- element1 name = e1 element2 name = e2 e1.src! e2.sink
source to share