목표
GStreamer-tools 은 코드없이 GStreamer 를 테스트 및 실행가능하게 한다.
pipelines, elements 와 같은 개념을 익히기 좋다.
Introduction
gst-launch-1.0
,gst-inspect-1.0
andgst-discoverer-1.0
위 세가지 툴에 대해서 알아본다.
gst-launch-1.0
이 툴은 pipelines 을 PLAYING 상태로 세팅하고, pipeline 이 잘 작동하는지 빠르게 체크할 수 있게 한다.
gst-launcher-1.0 자체는 기본적으로 개발자들을 위한 디버깅 툴이다. 코드로
gst_parse_launch
함수를 실행시키는 일을 줄여준다.
Elements
GStreamer 에는 기본적으로 Element 라는 단위가 존재한다. 위 그림에서 file-source, ogg-demuxer, video-sink 와 같은게 element 다.
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
위 명령어를 쳐본 모습이다.
pipeline 으로 넘겨주는 문법은 (!) 로 작성한다.
Properties
각 Element 에는 Property 가 붙을 수 있다.
Properties may be appended to elements, in the form *property=value *(multiple properties can be specified, separated by spaces). Use thegst-inspect-1.0
tool (explained next) to find out the available properties for an element.
gst-launch-1.0 videotestsrc pattern=11 ! videoconvert ! autovideosink
videotestsrc pattern=11
videotestsrc 의 property 로 pattern=11 을 넘겨준 것이다. 추후 설명할 gst-inspect 로 살펴볼 수 있다.
Named elements
각 요소들은 name 을 가질 수 있는데, 파이프라인에서 이전 파이프라인의 이름을 지정할 수 있다. 지정한 이름을 쓰려면 이름뒤에 .(dot) 을 붙이면 된다.
gst-launch-1.0 videotestsrc ! videoconvert ! tee name=t ! queue ! autovideosink t. ! queue ! autovideosink
tee 는 하나의 입력으로 들어와서 두개의 출력으로 파이프라인을 만든다.
tee 로 나눠진 파이프라인은 queue 로 받아서 autovideosink 로 출력되게 된다.
Pads
Pads 는 demux 나 어떠한 것들에 의해 나눠진 element 의 끝부분을 의미한다. 특정한 pad 를 지칭하기 위해서는, 이름.패드 식으로 쓴다.
예를 들면,
gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! matroskademux name=d d.video_00 ! matroskamux ! filesink location=sintel_video.mkv
name=d d.video_00 ! ...
와 같은 표현이 있다. 지정한 name 의 video_00 pad 를 쓰겠다는 의도다.
다음과 같은 표현을 보자.
gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! matroskademux name=d d.audio_00 ! vorbisparse ! matroskamux ! filesink location=sintel_audio.mka
demux 로 나뉜 데이터의 audio pad 를 filesink 를 이용해서 file 로 저장하는 모습이다.