Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:33:43+00:00 2026-05-26T23:33:43+00:00

Is there a way make a pipeline that will play any video file (which

  • 0

Is there a way make a pipeline that will play any video file (which will contain audio too)? I have tried linking elements like:

filesrc -> decodebin

along with

queue -> audioconvert -> autoaudiosink

and

queue -> autovideoconvert -> autovideosink

This causes two problems:

  1. A queue cannot be linked to an autovideoconvert.
  2. I have no idea how to implement a pad with the "pad-added" event, especially when the pipeline supports both audio and video.

I would like to know how to do this without the need for gst.parse_launch. Also, I want the pieline to work with any format I throw at it (like playbin), but cannot use a playbin as I will need to link other elements (level and volume).

Alternatively, is there a way to connect elements (such as level) to a playbin?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:33:44+00:00Added an answer on May 26, 2026 at 11:33 pm

    I’ve built an example video player that makes use of the elements you described.

    It should show you how to connect the pads to eachother dynamically.

    '''
    Copyright (c) 2011 Joar Wandborg <http://wandborg.se>
    
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    ---
    
    - A response to http://stackoverflow.com/questions/8187257/play-audio-and-video-with-a-pipeline-in-gstreamer-python/8197837
    - Like it? Buy me a beer! https://flattr.com/thing/422997/Joar-Wandborg
    '''
    
    import gst
    import gobject
    gobject.threads_init()
    import logging
    
    
    logging.basicConfig()
    
    _log = logging.getLogger(__name__)
    _log.setLevel(logging.DEBUG)
    
    
    class VideoPlayer(object):
        '''
        Simple video player
        '''
    
        source_file = None
    
        def __init__(self, **kwargs):
            self.loop = gobject.MainLoop()
    
            if kwargs.get('src'):
                self.source_file = kwargs.get('src')
    
            self.__setup()
    
        def run(self):
            self.loop.run()
    
        def stop(self):
            self.loop.quit()
    
        def __setup(self):
            _log.info('Setting up VideoPlayer...')
            self.__setup_pipeline()
            _log.info('Set up')
    
        def __setup_pipeline(self):
            self.pipeline = gst.Pipeline('video-player-pipeline')
    
            # Source element
            self.filesrc = gst.element_factory_make('filesrc')
            self.filesrc.set_property('location', self.source_file)
            self.pipeline.add(self.filesrc)
    
            # Demuxer
            self.decoder = gst.element_factory_make('decodebin2')
            self.decoder.connect('pad-added', self.__on_decoded_pad)
            self.pipeline.add(self.decoder)
    
            # Video elements
            self.videoqueue = gst.element_factory_make('queue', 'videoqueue')
            self.pipeline.add(self.videoqueue)
    
            self.autovideoconvert = gst.element_factory_make('autovideoconvert')
            self.pipeline.add(self.autovideoconvert)
    
            self.autovideosink = gst.element_factory_make('autovideosink')
            self.pipeline.add(self.autovideosink)
    
            # Audio elements
            self.audioqueue = gst.element_factory_make('queue', 'audioqueue')
            self.pipeline.add(self.audioqueue)
    
            self.audioconvert = gst.element_factory_make('audioconvert')
            self.pipeline.add(self.audioconvert)
    
            self.autoaudiosink = gst.element_factory_make('autoaudiosink')
            self.pipeline.add(self.autoaudiosink)
    
            self.progressreport = gst.element_factory_make('progressreport')
            self.progressreport.set_property('update-freq', 1)
            self.pipeline.add(self.progressreport)
    
            # Link source and demuxer
            linkres = gst.element_link_many(
                self.filesrc,
                self.decoder)
    
            if not linkres:
                _log.error('Could not link source & demuxer elements!\n{0}'.format(
                        linkres))
    
            linkres = gst.element_link_many(
                self.audioqueue,
                self.audioconvert,
                self.autoaudiosink)
    
            if not linkres:
                _log.error('Could not link audio elements!\n{0}'.format(
                        linkres))
    
            linkres = gst.element_link_many(
                self.videoqueue,
                self.progressreport,
                self.autovideoconvert,
                self.autovideosink)
    
            if not linkres:
                _log.error('Could not link video elements!\n{0}'.format(
                        linkres))
    
            self.bus = self.pipeline.get_bus()
            self.bus.add_signal_watch()
            self.bus.connect('message', self.__on_message)
    
            self.pipeline.set_state(gst.STATE_PLAYING)
    
        def __on_decoded_pad(self, pad, data):
            _log.debug('on_decoded_pad: {0}'.format(pad))
    
            if pad.get_caps()[0].to_string().startswith('audio'):
                pad.link(self.audioqueue.get_pad('sink'))
            else:
                pad.link(self.videoqueue.get_pad('sink'))
    
        def __on_message(self, bus, message):
            _log.debug(' - MESSAGE: {0}'.format(message))
            
    
    if __name__ == '__main__':
        player = VideoPlayer(
            src='/home/joar/Videos/big_buck_bunny_1080p_stereo.avi')
    
        player.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to make Python ignore any .pyc files that are present
Is there a way to make the banner images that are displayed in the
Is there any way to make Visual Studio 2008 Express store all the files
Is there any way to make Visual Studio word-wrap at 80 characters? I'm using
Is there way to make function in Action Script, or any other language, to
Is there any way to make resource forks uncopyable? In particular I'm setting a
Is there a way to make the Play! Framework ignore slashes and ? in
is there any way to make IIS language as English? my OS is currently
Is there a way to make MatrixForm display a row vector horizontally on the
Is there a way to make a TSQL variable constant?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.