<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>I try to understand the way Python and gstreamer works together.
      I'm able to build a pipeline for only video and that plays just
      fine, but when I add audio my pipeline stops by the first frame
      and put this to screen.</p>
    <p>Can you tell me, what is wrong with my code here?:</p>
    <blockquote>
      <p><font size="-1">#!/usr/bin/env python3<br>
          <br>
          import gi<br>
          gi.require_version('Gst', '1.0')<br>
          gi.require_version('GLib', '2.0')<br>
          from gi.repository import GLib, Gst<br>
          <br>
          # mode debugging infos<br>
          Gst.debug_set_active(True)<br>
          Gst.debug_set_default_threshold(3)<br>
          <br>
          <br>
          # callback link pads<br>
          def on_new_decoded_pad(dbin, pad):<br>
              type = pad.query_caps(None).to_string()<br>
              decode = pad.get_parent()<br>
              pipeline = decode.get_parent()<br>
          <br>
              if type.startswith("video"):<br>
                  video_queue = pipeline.get_by_name("video_queue")<br>
                  decode.link(video_queue)<br>
                  print("linked video")<br>
              if type.startswith("audio"):<br>
                  audio_queue = pipeline.get_by_name("audio_queue")<br>
                  decode.link(audio_queue)<br>
                  print("linked audio")<br>
          <br>
          <br>
          def main():<br>
              Gst.init(None)<br>
          <br>
              # create new pipeline<br>
              pipe = Gst.Pipeline.new('pipleline')<br>
          <br>
              # add source and decoder<br>
              src = Gst.ElementFactory.make('filesrc', "src")<br>
              decode = Gst.ElementFactory.make('decodebin', 'decode')<br>
          <br>
              # video queue and sink<br>
              video_queue = Gst.ElementFactory.make('queue',
          'video_queue')<br>
              video_sink = Gst.ElementFactory.make('autovideosink',
          'video_sink')<br>
          <br>
              # audio queue and sink<br>
              audio_queue = Gst.ElementFactory.make('queue',
          'audio_queue')<br>
              audio_convert = Gst.ElementFactory.make('audioconvert',
          'audio_convert')<br>
              audio_sink = Gst.ElementFactory.make('autovideosink',
          'audio_sink')<br>
          <br>
              # set some properties<br>
              src.set_property('location', 'test.mp4')<br>
              video_sink.set_property('sync', 'true')<br>
              audio_sink.set_property('sync', 'true')<br>
          <br>
              # create pipeline<br>
              pipe.add(src)<br>
              pipe.add(decode)<br>
              pipe.add(video_queue)<br>
              pipe.add(video_sink)<br>
              pipe.add(audio_queue)<br>
              pipe.add(audio_convert)<br>
              pipe.add(audio_sink)<br>
          <br>
              # link elements<br>
              src.link(decode)<br>
              video_queue.link(video_sink)<br>
              audio_queue.link(audio_convert)<br>
              audio_convert.link(audio_sink)<br>
          <br>
              # link decoder to coresponding queue<br>
              decode.connect('pad-added', on_new_decoded_pad)<br>
          <br>
              loop = GLib.MainLoop()<br>
          <br>
              # start pipeline in play mode<br>
              pipe.set_state(Gst.State.PLAYING)<br>
              loop.run()<br>
          <br>
              # cleanup<br>
              pipe.set_state(Gst.State.NULL)<br>
          <br>
          <br>
          if __name__ == '__main__':<br>
              main()</font><br>
      </p>
    </blockquote>
    <p><br>
    </p>
    <p>I hope it is ok, to post so much code here, when not I can post
      next time a gist link.</p>
    <p><br>
    </p>
    <p>Regards</p>
    <p>Jonathan<br>
    </p>
  </body>
</html>