$ sudo apt update && sudo apt upgrade
$ sudo apt-get dist-upgrade

 

glib 설치

1. glib download

https://download.gnome.org/sources/glib/

 

Index of /sources/glib/

 

download.gnome.org

2. 압축 풀기

~$ tar xvf glib-2.9.6.tar.gz

3. 구성

~$ cd glib-2.9.6/
~/glib-2.9.6$ ./configure

4. configure 중간에 없다고 오류나는 패키지들 설치

http://www.gnu.org/software/gettext/gettext.html

 

gettext - GNU Project - Free Software Foundation

gettext Usually, programs are written and documented in English, and use English at execution time for interacting with users. This is true not only from within GNU, but also in a great deal of proprietary and free software. Using a common language is quit

www.gnu.org

~$ sudo apt-get install gettext

 

GStreamer 설치

$ sudo apt update

설치

$ sudo apt install libgstreamer1.0-0 libgstreamer1.0-dev gstreamer1.0-tools gstreamer1.0-doc gstreamer1.0-x gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly  gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio libgstreamer-plugins-base1.0-dev

확인

$ gst-inspect-1.0 --version

웹캠 확인

$ gst-launch-1.0 autovideosrc device=/dev/video0 ! autovideosink

샘플코드

#include <gst/gst.h>
#include <iostream>

// compile & run
// $ g++ gstreamer_example.cpp -o gstreamer_example `pkg-config --cflags --libs gstreamer-1.0`
// $ ./gstreamer_example

int main() 
{
    GstElement *pipeline, *source, *sink;
    GstBus *bus;
    GstMessage *msg;
    GstStateChangeReturn ret;

    gst_init(NULL, NULL);

    pipeline = gst_pipeline_new ("pipeline");
    source = gst_element_factory_make ("autovideosrc", "source");
    sink = gst_element_factory_make ("autovideosink", "sink");

    if (!pipeline || !source || !sink) 
    {
        std::cout << "not all elements created: pipeline[" << !pipeline
            << "] source[" << !source
            << "] sink["<< !sink << "]" << std::endl;
        return -1;
    }

    g_object_set(G_OBJECT (sink), "sync", FALSE, NULL);

    gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
    if (gst_element_link (source, sink) != TRUE) 
    {
        std::cout << "Elements could not be linked." << std::endl;
        gst_object_unref (pipeline);
        return -1;
    }

    ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE) 
    {
        std::cout << "Unable to set the pipeline to the playing state." << std::endl;
        gst_object_unref (pipeline);
        return -1;
    }

    bus = gst_element_get_bus (pipeline);

    std::cout << "press CTRL + C" << std::endl;

    for (;;);

    gst_object_unref(bus);
    gst_element_set_state(pipeline, GST_STATE_NULL);
    gst_object_unref(pipeline);
}

컴파일 및 실행

$ g++ gstreamer_example.cpp -o gstreamer_example `pkg-config --cflags --libs gstreamer-1.0`

$ ./gstreamer_example

 

 

'OS > Linux' 카테고리의 다른 글

CMake Install  (0) 2022.10.01
VSCode: ssh로 접근해서 편집된 파일 저장 시 permission 문제  (0) 2022.08.22
WSL2에서 GUI 사용하기  (0) 2021.10.19
Installing Linux Developer Tools  (0) 2021.10.19
Linux OS version  (0) 2021.10.07

+ Recent posts