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

4.7k views Asked by At

I am trying to setup a pipeline to play just the video stream from an OGG file in Linux using gstreamer-0.10. I need to do this from the command line using the gst-launch utility. I am successfully able to play both the audio and video streams using the following command:

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

I am also able to setup a pipeline to play a video test file using the following command:

$ gst-launch-0.10 videotestsrc ! autovideosink

But I cannot seem to piece together the proper pipeline to play the video stream from the OGG demuxer.

According to the gstreamer documentation (Fig 3 - http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+3%3A+Dynamic+pipelines), the OGG demuxer video sink should be src_02. This appears to be supported by the gst-inspect command:

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

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

And according to this tutorial on specifying pads (http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+10%3A+GStreamer+tools), I believe that my command to play the video stream from my file would look like this:

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

But these are my run results. Everything appears to hang "prerolling" and I need to interrupt with a Ctrl+C to get back to the command line:

$ 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 ...

Any ideas?

Also potentially insightful:

$ 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

UPDATE: I was able to play just the audio stream using the following command:

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

Note that it does not work when using the filesrc location=demo.ogv. Only when I use the uridecodebin. And I am still unable to isolate the video stream.

UPDATE 2: I stumbled a pipeline that isolates and plays the video stream, but I do not understand it:

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

I found it while surfing (http://wiki.laptop.org/go/GStreamer/Developers) and saw a demo execution of videotestsrc.

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

Can anyone explain why this works? This would appear to encode the file, mux it, demux it, decode it, and then filter/scale it into the sink. How does this make sense?

2

There are 2 answers

1
Mathieu_Du On

This actually doesn't make sense, and is totally wrong :)

You will want to use :

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

to play only the video part. Using filesrc of course won't work because you will try to send the content of the files, so something muxed and encoded, to audioconvert which can only deal with raw audio. If you want to construct the entire pipeline by hand, you can do :

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

As a side note, you should use gstreamer 1.0 except if you have a very good reason not to.

Cheers :)

0
mpr On

If uridecodebin is known to be giving you a good video pipeline, and you just want to copy it, you can try the following.

1) set environment variable GST_DEBUG_DUMP_DOT_DIR.

export GST_DEBUG_DUMP_DOT_DIR=/tmp

2) Run your gst-launch command.

3) In /tmp you should see files like the following

  • 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) Install graphviz if you don't already have it.

5) Run the "dot" program to create a PNG file of the exact pipeline GStreamer used. Base it off the "PAUSED_PLAYING" file.

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