We will develop code that takes a video file as an input and then creates two output files, one with only the audio track of the original file and the other with the video portion.
Download the file
SeparatingAudio.py
from the Packt website. The structure of the classAudioSeparator
is similar to the one seen in the Playing a Video section. We will review two methods of this class,constructPipeline
anddecodebin_pad_added
.Let's start with the code in the
constructPipeline
method.1 def constructPipeline(self): 2 # Create the pipeline instance 3 self.player = gst.Pipeline() 4 5 # Define pipeline elements 6 self.filesrc = gst.element_factory_make("filesrc") 7 8 self.filesrc.set_property("location", 9 self.inFileLocation) 10 11 self.decodebin = gst.element_factory_make("decodebin") 12 13 self.autoconvert = gst.element_factory_make( 14 "autoconvert...