videos with no audio streams - python gstreamer

Robert Kesterson robertk at robertk.com
Wed Mar 14 09:21:04 PDT 2012


On 3/14/2012 10:51 AM, Robert Kesterson wrote:
> On 3/13/2012 12:02 PM, Adrian Ulges wrote:
>> Hi there,
>>
>> I'm using gstreamer for python (python-gst0.10) for extracting audio
>> streams from video files:
>> ...
>> The problem is: when opening a video with no audio stream, the code
>> freezes on the 'sink.emit' statement.
>>
>> My question is: Is there a way to check files for the presence of
>> audio streams (preferably in python-gst), or is there a way to check a
>> pipeline before pulling data, or can I get it to throw an error
>> instead of freezing?
>
> You can use discoverer to find out about the audio streams.  Something 
> along the lines of:
>
>         import gst.pbutils
>
>         discoverer = gst.pbutils.Discoverer(50000000000)
>         info = discoverer.discover_uri(filename)    # needs to start 
> with file:// for local files
>         info.get_stream_info()
>         for sinfo in info.get_stream_list():
>             if isinstance(info, gst.pbutils.DiscovererAudioInfo):
>                 # you've got audio
>                 ...
>             elif isinstance(info, gst.pbutils.DiscovererVideoInfo):
>                 # you've got video
>                 ...

Oops.  Those isinstance lines should be about "sinfo", not "info".  But 
hopefully you get the idea.

-- 
   Robert Kesterson
   robertk at robertk.com



More information about the gstreamer-devel mailing list