Let's write a utility that can mix two audio streams together.
Download the file
AudioMixer.py
which contains the source code for this utility.Now we will review the
constructPipeline
method. The API methodgst.parse_launch()
explained in the previous chapter will be used here.1 def constructPipeline(self): 2 audio1_str = (" filesrc location=%s ! " 3 "decodebin ! audioconvert ! " 4 % (self.inFileLocation_1) ) 5 6 audio2_str = ( " filesrc location=%s " 7 "! decodebin ! audioconvert ! " 8 %(self.inFileLocation_2) ) 9 10 interleave_str = ( "interleave name=mix ! " 11 " audioconvert ! lame ! " 12 " filesink location=%s"%self.outFileLocation ) 13 14 queue_str = " ! queue ! mix." 15 16 myPipelineString = ( 17 interleave_str + audio1_str + queue_str + 18 audio2_str + queue_str ) 19 20 self.pipeline = gst.parse_launch(myPipelineString)
The
audio1_str
andaudio2_str
are the portions of the...