LoginSignup
2
3

More than 5 years have passed since last update.

parsebin を試す

Posted at

parsebin

decodebin3 で使われている parsebin というエレメントで今日は遊んでみようと思います。

ネコの動画をパースしてみる

こんな感じで実行すると...

$ GST_DEBUG=parsebin:5 gst-launch-1.0 filesrc location=neko_1213a2.mov ! parsebin ! fakesink

↓結果(抜粋)

0:00:00.045106106 29005 0x5622fd357ca0 DEBUG               parsebin gstparsebin.c:3879:gst_parse_pad_update_caps:<'':parsepad1> Storing caps image/jpeg, parsed=(boolean)true, width=(int)640, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1 on stream <stream1>

パース結果がログとして表示ます! 中身は image/jpeg だったことがわかります。

コンテナの中が H.264 なのか jpeg なのかわからない時や、ネットワークストリーミングで来てるフォーマットがわからない時などにparsebin便利。

UVCカメラの映像をパースしてみる

おもむろに v4l2src を parsebin に食わせると...

$ GST_DEBUG=parsebin:5 gst-launch-1.0 v4l2src ! parsebin ! fakesink

↓結果(抜粋)

0:00:01.885670151 29258 0x559a51e0a400 DEBUG               parsebin gstparsebin.c:1232:copy_sticky_events:<'':parsepad0> store sticky event caps event: 0x559a51e06df0, time 99:99:99.999999999, seq-num 24, GstEventCaps, caps=(GstCaps)"video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive\,\ colorimetry\=\(string\)2:4:7:1\,\ framerate\=\(fraction\)5/1";

カメラはYUVのFullHDを出していることがわかります!

しかし、YUV は非圧縮のデータなので、デコードできるはずはないんですがデコーダーを探そうとしてこんなメッセージもでます。

エレメントが見つかりません: Uncompressed packed YUV  デコーダー
ERROR: from element /GstPipeline:pipeline0/GstParseBin:parsebin0: GStreamer はプラグインを見つけることができません
追加のデバッグ情報:
gstparsebin.c(3461): gst_parse_bin_expose (): /GstPipeline:pipeline0/GstParseBin:parsebin0:
no suitable plugins found:
Missing decoder: Uncompressed packed YUV  (video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)2:4:7:1, framerate=(fraction)5/1)

う〜ん、これをERROR:として出すかどうかは悩みどころな気もする...

plane textをパースしてみる

ついでに映像以外をパースしてみると...

$ gst-launch-1.0 filesrc location=README.md ! parsebin ! fakesink
パイプラインを一時停止 (PAUSED) にしています...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstParseBin:parsebin0: これはテキストファイルのようです
追加のデバッグ情報:
gstparsebin.c(2379): type_found (): /GstPipeline:pipeline0/GstParseBin:parsebin0:
ParseBin cannot decode plain text files
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

おお、こちらもいい感じに結果がでますね...

おわり

たまに取り扱うファイルの詳細情報(フレームレートとかアスペクト比とか)知りたい時とかあるんですが、意外とそれらの情報って取得するのってめんどくさいんですよね...

これからは parsebin におまかせです :)

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3