Gstreamer bad plugins windows

GStreamer: кодеки с привкусом Linux

Вы когда-нибудь задумывались о том как работают Gnome-плееры, такие как Totem, Rhythmbox или Banshee? Наверное каждый из вас в новоустановленной Ubuntu, при попытке проиграть AVI-шку видел сообщение о необходимости установить дополнительный пакет gst-ffmpeg или gst-plugins-ugly. Под катом — моя попытка прояснить свет на то, как работает этот мультимедийный фреймворк и на что он способен.

Основное отличие от VLC или FFmpeg в том, что первоначально среда разрабатывалась не для определённого приложения, а для всех программ, которые могут работать с мультимедиа. Данный фреймворк интегрирован в такие языки: С, С++/Qt, Python, Ruby, Perl.

GStreamer позволяет создавать приложения, которые способны:
  • Принимать и передавать аудио-видео, используя практически любой протокол: HTTP, RTSP/RTP, MMS, RTMP и другие.
  • Разбирать/Собирать потоки в разных форматах: MPEG,AVI,ASF,FLV,MKV и другие.
  • Вытягивать и вставлять метаданные в файлах.
  • Декодировать/Кодировать потоки практически в любой комбиации кодеков.
    При этом можно использовать не только open-source решения (libavcodec, libmp3lame, libfaac), но и проприетарные, которые можно купить. Так-же можно задействовать декодеры с аппаратной поддержкой c использованием технологий CUDA/VAAPI/CrystalHD.
  • Выводить потоки на экран или звуковую карту, используя самые разнообразные решения, начиная от DirectFB, и заканчивая X-ами.

Для решения таких задач, как перекодирование фильма в другой формат, большую популярность имеют такие программы как mencoder или VLC. Но сделать то-же самое при помощи GStreamer — не на много сложнее.

Ниже представлены примеры для Linux, демонстрирующие возможности фреймворка. В этих примерах мы будем использовать основные программы gst-launch и gst-inspect — чем-то напоминающие Windows-приложение GraphEdit. Для тех, кому нужна графическая оболочка — есть gst-editor. Но учтите, что эти программы предназначены для отладки, поэтому не ожидайте от них удобства в использовании.

Для начала работы с GStreamer необходимо уяснить некоторые понятия:

  • element — Элемент-объект GStreamer’а, который может принимать/отправлять данные.
  • source — Генерирует поток (файл, поток или устройство).
  • filter — Элемент, который трансформирует поток (парсеры, мультиплексоры, кодеки).
  • sink — Принимает поток и не перенаправляет его.
  • pipeline — Коллекция соединённых между собой элементов.

В классическом виде мы получаем такого вида цепочку: source -> parser -> decoder -> filter -> sink.

Если вам лень собирать всю цепочку кодеков и мультиплексоров вручную, GStreamer может сделать это за вас:

Элемент «playbin» сам разбирает файл, находит нужный кодек и элемент вывода. Всё что нужно — указать путь к файлу, который нужно проиграть. Если-же вам интересно какой элемент за что отвечает, вы можете запустить gst-inspect и увидеть все доступные элементы, а «gst-inspect lame» — покажет парамерты mp3-кодера. Так-же стоит отметить полезность элемента «decodebin2», который сам находит нужный декодер.

$ gst-launch filesrc location=audio.mp3 ! decodebin2 ! alsasink

Простейший аудиоплеер (выбираем кодек вручную, и согласовываем форматы):

$ gst-launch filesrc location=audio.mp3 ! mad ! audioconvert ! audioresample ! alsasink

Плеер посложнее (со звуком и видео):

$ gst-launch filesrc location=audovideofile.mpeg ! decodebin2 name=decoder \
decoder. ! ffmpegcolorspace ! xvimagesink \
decoder. ! audioconvert ! audioresample ! alsasink

Если вам нужно перекодировать AVI-файл в MOV, можно воспользоваться следующей командой:

Читайте также:  Почему хакеры предпочитают линукс

Хочется сделать вещание, одновременно с записью в файл и отображением на экране вещаемого видео? Без проблем:

$ gst-launch v4l2src ! queue ! \
ffmpegcolorspace ! tee name=t1 ! \
queue ! xvimagesink sync=false t1. ! \
queue ! theoraenc quality=1 ! \
queue ! oggmux name=mux \
alsasrc ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! \
queue ! audioconvert ! vorbisenc ! \
queue ! mux. mux. ! \
queue ! tee name= t ! \
queue ! filesink location=test.ogg t. ! \
queue ! shout2send ip= port=8000 password=hackme

Любители повещать во флеше — тоже не остались в стороне, благодаря librtmp (надо пересобрать пакет gst-plugins-bad):

$ gst-launch v4l2src ! \
queue ! ffmpegcolorspace ! ffenc_flv ! \
queue ! flvmux name=muux is-live=true ! \
rtmpsink location=’rtmp://localhost/path/to/stream live=1′ \
alsasrc ! audio/x-raw-int,rate=22050,channels=1,depth=16 ! \
queue ! audioconvert ! lame bitrate=48 ! \
queue ! muux.

Так-же разработчики позаботились об использовании «родных» мультимедийных фреймворков (QuickTime/DirectShow), если вы используете MacOS или Windows, благодаря «мостам».

Ну и в заключение хочется сказать, что есть немало проблем, которые ещё предстоит решить разработчикам (рассинхронизации, проблемы с утечками памяти и производительности). Большинство из них связано с использованием сторонних библиотек, которые не всегда качественно написаны. Вот поэтому разработчики и придумали интересный приём — плагины разделены на 5 категорий:

  • gst-plugins-base — Основные плагины, идущие в комплекте: CDDA, RTP, RTSP, ogg, theora, vorbis, Xvideo, V4L.
  • gst-plugins-good — Плагины, не вызываюшие сомнения в своей надёжности: FLAC, speex, JPEG, PNG.
  • gst-plugins-bad — Рабчие, но возможны проблемы: VP8, XVID, FAAC, dirac, RTMP, VDPAU, DirectShow.
  • gst-plugins-ugly — Не обойтись без проблем при использовании: ASF, real, DVDSub, a52, AMR, x264.
  • gst-ffmpeg — Отдельный набор кодеков «всё в одном».

Gstreamer bad plugins windows

I created a very simple project with one source file (main.cpp) to render video from a Gstreamer pipeline into a QWidget. It builds and runs properly on OSX but not Windows. I tried with Gstreamer MinGW 64 and 32 as well as with MSVC 64. My error is:

Project ERROR: gstreamer-1.0 development package not found

I saw this post: https://forum.qt.io/topic/74652/building-qt-gstreamer . but before stepping through its recommendations I was hoping to get a more recent update on the correct steps.

Here is my .pro file:

Here is main.cpp

Hi and welcome to devnet,

Might be a silly question but do you have the pkg-config files for GStreamer on Windows ?

Great to meet you!

Here are my pkg-config files for «gstreamer»:

Since you are using the full path to the executable, did you modify the PATH environment variable in the Build part of the Project panel so that it can be found by qmake ?

Читайте также:  Msi h110m pro vd plus драйвера windows 10

Did you also try it set the PKG_CONFIG_PATH environment variable ?

This is what I now have. Please suggest the value for the PKG_CONFIG_PATH variable. Also please confirm that I should be doing with this with Gstreamer MinGW-64. Finally, please help me understand why Windows is asking for this: «Project ERROR: gstreamer-1.0 development package not found» while it builds fine on MacOS. It looks like they have the same pkg-config gstreamer libs.


should contain paths to folder containing .pc files.

Just an educated guess but pkg-config was likely not developed with Windows in mind when it was released.

OK. I found it here:
C:>dir «C:» /s /b /d | find «.pc»
.
C:\gstreamer\1.0\x86_64\lib\pkgconfig\x264.pc
C:\gstreamer\1.0\x86_64\lib\pkgconfig\zlib.pc
. etc
and set it here but got the same error:
..

Did you also modify the PATH environment variable so that pkg-config can be found by Qt Creator ?

Done. Same error.

I did not build qt-gstreamer on any platform. It compiled as-is on Linux and MacOS with the Gstreamer installs but perhaps I need to build an install this as per this article?

Path contains a folder list, not full executable path.

There’s no need to build QtGstreamer which is deprecated by the way.

Path updated. Still no luck.

Did you force a re-run of qmake after these modifications ?

I re-started QT Creator and made a point of changing the .pro file. It re-parse and reset.

I did a clean install of QT Creator with the MSVC Gstreamer installers and got past that initial error. Now my error is in the Gstreamer integration code. I consider this progress!

Making some progress. Now it is compiling after I added:

Now we are trying to get gstreamer to find its own plugins:

14:31:17: Starting C:\GIT\build-slim-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\slim.exe .

(slim.exe:4476): GStreamer-WARNING **: 14:31:24.371: Failed to load plugin ‘C:\gstreamer\1.0\x86_64\lib\gstreamer-1.0\gstopenh264.dll’: ‘C:\gstreamer\1.0\x86_64\lib\gstreamer-1.0\gstopenh264.dll’: The specified procedure could not be found.

(slim.exe:4476): GStreamer-WARNING **: 14:31:25.826: Failed to load plugin ‘C:\gstreamer\1.0\x86_64\lib\gstreamer-1.0\gstsrt.dll’: ‘C:\gstreamer\1.0\x86_64\lib\gstreamer-1.0\gstsrt.dll’: The specified procedure could not be found.
WARNING: no real random source present!
14:31:30: C:\GIT\build-slim-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\slim.exe exited with code 1

This does the trick for making sure that Gstreamer finds its own plugins:

Also here is my win32 block in my .pro file for reference:

Looks like pkg-config did not work correctly but still. the manual way did work !

Glad you found a way and thanks for sharing !

Also for Windows, I needed to use d3dvideosink or autovideosink rather than glimagesink

Читайте также:  Как убрать экран выбора при загрузке windows

It builds and renders the Gstreamer sample video.

Now my issue is getting it to stay within the application window rather than popping out into its own new window.

I got this error:

So I am wondering why gst_video_overlay_set_window_handle failed.

You might want to take a look at the GStreamer backend plugin. With recent versions of Qt you can build custom pipelines and make them output to a Qt video widget naming the sink properly.

I would love to learn more about that. May I have a pointer to a doc? A quick search did not turn up an obvious resource for me.

I got it to land in the QWidget. The trick was to call .show() before calling winId().

Here is the final .pro:

and project build ENV settings:

QMediaPlayer::setMedia for thé documentation itself.

You might even be able just build the GStreamer backend and use it directly.

I thought that QMediaPlayer used native AV Foundations (Windows Media Foundation for Windows, AV Foundation for MacOS, and GStreamer for Linux) . does this mean that I can now use a gst-pipeline source for QMediaPlayer in an App on Windows or Mac?

QMediaPlayer does not do anything directly. It uses the various plugins. Each platform has its corresponding plugin using native technologies. However nothing forbids you to provide additional plugins like for example for network cameras. So if you manage to build the GStreamer plugin, using it should also be possible.

Got it. Thank you!

I spoke too soon. I do have the application building but video is not yet playing. I was told that the issue may be because I am using MinGW rather than MSVC. I was able to trim down a sample application which I thought that I should share in case anyone else wants to give this a try. I see the video test pattern when I build it from QT Creator but not when I deploy it as a stand alone application. If you are able to see the test pattern as a stand alone application, please post here how you got it working. Thank you!

Did you deploy your application using windeployqt ?

Yes. It still needed the Gstreamer libs, so I copied all of those too. It also complained of other libs missing so I copied those as needed from the system until the application ran. Now it runs but video does not play. I suspect that this may be the mysterious issue with MinGW.

Оцените статью