[gst-devel] How can I get full information about a media file?

LRN lrn1986 at gmail.com
Tue Mar 30 19:11:16 CEST 2010


On 30.03.2010 19:11, wl2776 wrote:
> I need to know the number of streams in a file (video, audio, subtitles,
> etc).
> How can I do this?
>
> typefind element returns something simple and generic, like video/x-msvideo,
> or "video/mpeg, systemstream=(boolean)true, mpegversion=(int)2"
>
> I tried to set up a pipeline: filesrc ! decodebin2 ! fakesink, but fakesink
> is not linked, and decodebin2 doesn't construct the same complex pipeline,
> like it did while included in the playbin2.
>   
An approach that worked for me:

Create a pipeline, bus.
Create uridecodebin, set its uri property (or create filesrc, decodebin
and link them)
Set up "no-more-pads", "unknown-type" handlers
Add to pipeline, link.
Set pipeline to PAUSED
Pull messages from the bus and send them to your bus message handler
until it returns FALSE.

bus message handler should:
return FALSE on GST_MESSAGE_ASYNC_DONE
set pipeline state to NULL and return FALSE on GST_MESSAGE_EOS
memorize each tag from GST_MESSAGE_TAG messages (if you want to read tags)
return FALSE on error
otherwise return TRUE

"no-more-pads" handler should:
gst_element_iterate_src_pads of uridecodebin
each pad corresponds to a stream. You can also get stream caps (stream
information) there. To keep pipeline working you also have to extend
pipeline by linking elements to each pad (if you don't it will crash due
to being 'not-linked'). In your case fakesink should do the trick (since
you don't seem to be interested in data).

"unknown-type" handler will allow you to obtain stream caps for streams
that GStreamer can't decode (you might want them too).




More information about the gstreamer-devel mailing list