달력

32024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형

GStreamer References

- Tutorial 10: https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c

- Tutorial 1: https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c

 

Installing GStreamer on Mac OS X

Ref: https://gstreamer.freedesktop.org/documentation/installing/on-mac-osx.html?gi-language=c

pkg 파일을 받아 SDK 설치

note. brew로 애써봤는데 SDK가 아니라서 안 됨. 포기.

pkg 설치 후 GStreamer를 사용하기 위한 경로

더보기
  • /Library/Frameworks/GStreamer.framework/: Framework's root path
  • /Library/Frameworks/GStreamer.framework/Versions: path with all the versions of the framework
  • /Library/Frameworks/GStreamer.framework/Versions/Current: link to the current version of the framework
  • /Library/Frameworks/GStreamer.framework/Headers: path with the development headers
  • /Library/Frameworks/GStreamer.framework/Commands: link to the commands provided by the framework, such as gst-inspect-1.0 or gst-launch-1.0

 

SDK가 제대로 설치되었는지 확인하기 위한 예제 실행

Visual Studio Code 설정

note. XCode 사용 안 할 예정

아래 main.c 컴파일하기

#include <gst/gst.h>

int
main(int argc, char *argv[])
{
  gst_init(NULL, NULL);

  return 0;
}

.vscode/c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/Library/Frameworks/GStreamer.framework/Headers"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "macos-clang-arm64"
        }
    ],
    "version": 4
}

.vscode/task.json

{
    "options": {
        "env": {
            "GST_DEBUG": "*:WARN",
            "GIO_EXTRA_MODULES": "/Library/Frameworks/GStreamer.framework/Libraries/gio/modules/"
        }
    },
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang 활성 파일 빌드",
            "command": "/usr/bin/clang",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-I/Library/Frameworks/GStreamer.framework/Headers",
                "-L/Library/Frameworks/GStreamer.framework/Libraries",
                "-F/Library/Frameworks",
                "-framework",
                "GStreamer"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "디버거에서 생성된 작업입니다."
        }
    ],
    "version": "2.0.0"
}

note. pkg-config 컴파일 방법

더보기
# Tell pkg-config where to find the .pc files
$ export PKG_CONFIG_PATH=/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig

# We will use the pkg-config provided by the GStreamer.framework
$ export PATH=/Library/Frameworks/GStreamer.framework/Versions/1.0/bin:$PATH

# Compile
$ clang -c main.c -o main.o `pkg-config --cflags gstreamer-1.0`

# Link
$ clang -o main main.o `pkg-config --libs gstreamer-1.0`

실행결과: 빈 화면. 단, 디버그 시 GStreamer 라이브러리들을 불러오는 것을 확인할 수 있다.

근데 이게 되면 tutorial 1을 바로 처리할 수 있다.

 

Basic tutorial 1: Hello world!

- Tutorial 1: https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c

아래 basic-tutorial-1.c 컴파일

#include <gst/gst.h>

#ifdef __APPLE__
#include <TargetConditionals.h>
#endif

int
tutorial_main (int argc, char *argv[])
{
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Build the pipeline */
  pipeline =
      gst_parse_launch
      ("playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm",
      NULL);

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg =
      gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
      GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* See next tutorial for proper error message handling/parsing */
  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
    g_error ("An error occurred! Re-run with the GST_DEBUG=*:WARN environment "
        "variable set for more details.");
  }

  /* Free resources */
  gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

int
main (int argc, char *argv[])
{
#if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
  return gst_macos_main (tutorial_main, argc, argv, NULL);
#else
  return tutorial_main (argc, argv);
#endif
}

근데, Exception

Troubleshooting

GST_DEBUG=*:WARN 환경변수 걸고 실행.

0:00:00.033862000 61664    0x11d80e9e0 WARN             souphttpsrc gstsouphttpsrc.c:1632:gst_soup_http_src_parse_status:<source> error: Secure connection setup failed.
0:00:00.033877000 61664    0x11d80e9e0 WARN             souphttpsrc gstsouphttpsrc.c:1632:gst_soup_http_src_parse_status:<source> error: TLS/SSL support not available; install glib-networking (6), URL: https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm, Redirect to: (NULL)
0:00:00.033907000 61664    0x11d04c4c0 WARN                 basesrc gstbasesrc.c:3132:gst_base_src_loop:<source> error: Internal data stream error.

** (basic-tutorial-1:61664): ERROR **: 00:18:02.409: An error occurred! Re-run with the GST_DEBUG=*:WARN environment variable set for more details.
0:00:00.033914000 61664    0x11d04c4c0 WARN                 basesrc gstbasesrc.c:3132:gst_base_src_loop:<source> error: streaming stopped, reason error (-5)
[1]    61664 trace trap  GST_DEBUG=*:WARN ./basic-tutorial-1

https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm 이 파일이 404인 건 아님

메시지에 install glib-networking 이 보이지만 이미 설치됨

검색해보니 이슈가 나옴: https://stackoverflow.com/questions/73921225/gstreamer-tls-ssl-support-not-available-error-on-mac

더보기

$ export GIO_EXTRA_MODULES=/Library/Frameworks/GStreamer.framework/Libraries/gio/modules/

task.json 수정(위)하여 다시 시도.

실행결과: 비디오 재생

정리

gst_init -> (파이프라인만 실행시킨다면) gst_parse_launch -> [optional] gst_element_set_state -> (gst_element_get_bus) gst_bus_timed_pop_filtered (오류 또는 EOS 까지 대기) -> [cleanup] gst_message_unref, gst_object_unref(bus, pipeline)

 

Basic Tutorial 10: GStreamer tools

- Tutorial 10: https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c

gst-launch-1.0 을 위해 PATH(/Library/Frameworks/GStreamer.framework/Commands) 추가

이 튜토리얼의 목적은 GST 파이프라인의 이해. Tutorial 3의 파이프라인 버전

이 그림은 다음 예제의 파이프라인과 같긴 한데, 실행은 안 됨

gst-launch-1.0 uridecodebin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm name=d ! queue ! theoraenc ! oggmux name=m ! filesink location=sintel.ogg d. ! queue ! audioconvert ! audioresample ! flacenc ! m.

 

playbin => gst-launch-1.0 filesrc location=sintel_trailer-480p.webm ! matroskademux name=d ! queue ! vp8dec ! videoconvert ! autovideosink d. ! queue ! vorbisdec ! audioconvert ! audioresample ! autoaudiosink

 

파이프라인을 자세히 알고 싶으면 gst-inspect-1.0, 미디어 파일을 자세히 알고 싶으면 gst-discoverer-1.0

https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c

 

 

 

반응형
Posted by Taekhan
|