簡體   English   中英

如何在Linux中使用gstreamer播放OGG文件中的視頻流

[英]How to play the video stream from an OGG file using gstreamer in Linux

我正在嘗試建立一個管道,以使用gstreamer-0.10在Linux中僅播放來自OGG文件的視頻流。 我需要使用gst-launch實用程序從命令行執行此操作。 我可以使用以下命令成功播放音頻和視頻流:

$ gst-launch-0.10 playbin uri=file:///projects/demo.ogv

我還可以使用以下命令設置管道來播放視頻測試文件:

$ gst-launch-0.10 videotestsrc ! autovideosink

但是我似乎無法拼湊出適當的管道來播放OGG多路分配器的視頻流。

根據gstreamer文檔(圖3- http: //docs.gstreamer.com/display/GstSDK/Basic+tutorial+3%3A+Dynamic+pipelines),OGG多路分配器視頻接收器應為src_02。 這似乎受gst-inspect命令支持:

$ gst-inspect oggdemux
...
Pad Templates:
SRC template: 'src_%d'
    Availability: Sometimes
    Capabilities:
    ANY

SINK template: 'sink'
    Availability: Always
    Capabilities:
      application/ogg
      application/x-annodex
...

並且根據有關指定填充板的本教程( http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+10%3A+GStreamer+tools ),我相信我播放文件中視頻流的命令會看起來像這樣:

$ gst-launch-0.10 filesrc location=demo.ogv ! oggdemux name=d d.src_02 ! theoradec ! autovideosink

但是這些是我的跑步成績。 一切似乎都掛起了“ prerolling”,我需要用Ctrl + C中斷才能返回命令行:

$ gst-launch-0.10 filesrc location=demo.ogv ! oggdemux name=d d.src_02 ! theoradec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
^C
Caught interrupt -- handling interrupt.
Interrupt: Stopping pipeline ...
(gst-launch-0.10:7625): GLib-CRITICAL **: Source ID 1 was not found when attempting to remove it
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

有任何想法嗎?

也可能很有見地:

$ gst-typefind-0.10 demo.ogv 
demo.ogv - application/x-annodex

$ gst-discoverer-0.10 demo.ogv 
Analyzing file:///projects/keypr/demo.ogv
Done discovering file:///projects/keypr/demo.ogv

Topology:
  container: Ogg
    audio: Vorbis
    video: Theora

Properties:
  Duration: 0:00:05.546666666
  Seekable: yes
  Tags: 
      container format: Ogg
      application name: ffmpeg2theora-0.26
      extended comment: SOURCE_OSHASH=d1af78a82e61d18f
      encoder: Xiph.Org libtheora 1.1 20090822 (Thusnelda)
      encoder version: 0
      nominal bitrate: 110000
      bitrate: 110000
      video codec: Theora
      audio codec: Vorbis

更新:我能夠使用以下命令僅播放音頻流:

$ gst-launch-0.10 uridecodebin uri=file:///path/to/demo.ogv ! audioconvert ! autoaudiosink

請注意,在使用filesrc location=demo.ogv時,它不起作用。 僅當我使用uridecodebin時。 而且我仍然無法隔離視頻流。

更新2:我偶然發現了隔離並播放視頻流的管道,但我不明白:

$ gst-launch-0.10 uridecodebin uri=file:///path/to/demo.ogv ! theoraenc ! oggmux ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink

我在沖浪時( http://wiki.laptop.org/go/GStreamer/Developers )找到了它,並觀看了videotestsrc的演示執行。

$ gst-launch-0.10 videotestsrc ! theoraenc ! oggmux ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink

誰能解釋為什么這可行? 這似乎是對文件進行編碼,對其進行多路復用,對其進行解復用,對其進行解碼,然后將其過濾/縮放到接收器中。 這有什么意義?

如果已知uridecodebin為您提供了良好的視頻管道,而您只想復制它,則可以嘗試以下操作。

1)設置環境變量GST_DEBUG_DUMP_DOT_DIR。

export GST_DEBUG_DUMP_DOT_DIR=/tmp

2)運行您的gst-launch命令。

3)在/ tmp中,您應該看到如下文件

  • 0.00.00.010839464-gst-launch.NULL_READY.dot
  • 0.00.00.100795940-gst-launch.READY_PAUSED.dot
  • 0.00.00.104255451-gst-launch.PAUSED_PLAYING.dot
  • 0.00.00.988712046-gst-launch.PLAYING_READY.dot

4)如果尚未安裝graphviz,請安裝它。

5)運行“點”程序,以創建所使用的確切管道GStreamer的PNG文件。 以“ PAUSED_PLAYING”文件為基礎。

dot -Tpng 0.00.00.104255451-gst-launch.PAUSED_PLAYING.dot  -o /tmp/out.png

這實際上是沒有意義的,並且是完全錯誤的:)

您將要使用:

gst-launch-0.10 uridecodebin uri=file:///path/to/demo.ogv ! ffmpegcolorspace ! autovideosink

僅播放視頻部分。 使用filesrc當然是行不通的,因為您將嘗試將文件的內容(經過混合和編碼的內容)發送到audioconvert,而后者只能處理原始音頻。 如果要手動構建整個管道,可以執行以下操作:

gst-launch-0.10 filesrc location=demo.ogv ! oggdemux ! theoradec ! ffmpegcolorspace ! autovideosink

附帶說明,除非有充分理由不這樣做,否則應使用gstreamer 1.0。

干杯:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM