def __init__(self, FILECHOSEN, FILENAME, CONTAINERCHOICE, AUDIOCODECVALUE, VIDEOCODECVALUE): gobject.GObject.__init__(self) # create a dictionay taking the Codec/Container values and mapping them with plugin names # No asfmux atm, hopefully Soc will solve that # Choose plugin based on Codec Name audiocaps = codecfinder.codecmap[AUDIOCODECVALUE] videocaps = codecfinder.codecmap[VIDEOCODECVALUE] self.AudioEncoderPlugin = codecfinder.get_audio_encoder_element(audiocaps) self.VideoEncoderPlugin = codecfinder.get_video_encoder_element(videocaps) # print "Audio encoder plugin is " + self.AudioEncoderPlugin # print "Video encoder plugin is " + self.VideoEncoderPlugin # Choose plugin and file suffix based on Container name containercaps = codecfinder.containermap[CONTAINERCHOICE] self.ContainerFormatPlugin = codecfinder.get_muxer_element(containercaps) # print "Container muxer is " + self.ContainerFormatPlugin self.ContainerFormatSuffix = codecfinder.csuffixmap[CONTAINERCHOICE] # Remove suffix from inbound filename so we can reuse it together with suffix to create outbound filename self.FileNameOnly = os.path.splitext(os.path.basename(FILENAME))[0] self.VideoDirectory = glib.get_user_special_dir(glib.USER_DIRECTORY_VIDEOS) CheckDir = os.path.isdir(self.VideoDirectory) if CheckDir == (False): os.mkdir(self.VideoDirectory) # elif CheckDir == (True): # print "Videos directory exist" # print self.VideoDirectory # create a variable with a timestamp code timeget = datetime.datetime.now() text = timeget.strftime("-%H%M%S-%d%m%Y") self.timestamp = str(text) self.pipeline = gst.Pipeline("TranscodingPipeline") self.pipeline.set_state(gst.STATE_PAUSED) self.uridecoder = gst.element_factory_make("uridecodebin", "uridecoder") self.uridecoder.set_property("uri", FILECHOSEN) # print "File loaded " + FILECHOSEN self.uridecoder.connect("pad-added", self.OnDynamicPad) self.pipeline.add(self.uridecoder) self.containermuxer = gst.element_factory_make(self.ContainerFormatPlugin, "containermuxer") self.pipeline.add(self.containermuxer) self.transcodefileoutput = gst.element_factory_make("filesink", "transcodefileoutput") self.transcodefileoutput.set_property("location", (self.VideoDirectory+self.FileNameOnly+self.timestamp+self.ContainerFormatSuffix)) self.pipeline.add(self.transcodefileoutput) self.containermuxer.link(self.transcodefileoutput) self.uridecoder.set_state(gst.STATE_PAUSED) self.BusMessages = self.BusWatcher() self.uridecoder.connect("no-more-pads", self.noMorePads) # we need to wait on this one before going further
def check_for_elements(self): if self.container==False: containerstatus=True videostatus=True else: containerchoice = self.builder.get_object ("containerchoice").get_active_text () containerstatus = codecfinder.get_muxer_element(codecfinder.containermap[containerchoice]) if self.havevideo: if self.videopasstoggle != True: if self.VideoCodec == "novid": videostatus=True else: videostatus = codecfinder.get_video_encoder_element(self.VideoCodec) else: videostatus=True if self.haveaudio: if self.audiopasstoggle != True: audiostatus = codecfinder.get_audio_encoder_element(self.AudioCodec) else: audiostatus=True else: audiostatus=True if self.havevideo == False: # this flags help check if input is audio-only file videostatus=True if not containerstatus or not videostatus or not audiostatus: self.missingtoggle=True fail_info = [] if self.containertoggle==True: audiostatus=True videostatus=True if containerstatus == False: fail_info.append(gst.caps_from_string(codecfinder.containermap[containerchoice])) if audiostatus == False: fail_info.append(self.AudioCodec) if videostatus == False: fail_info.append(self.VideoCodec) missing = [] for x in fail_info: missing.append(gst.pbutils.missing_encoder_installer_detail_new(x)) context = gst.pbutils.InstallPluginsContext () context.set_xid(self.TopWindow.get_window().xid) strmissing = str(missing) gst.pbutils.install_plugins_async (missing, context, \ self.donemessage, "NULL")
def check_for_elements(self): containerchoice = self.get_widget ("containerchoice").get_active_text () containerstatus = codecfinder.get_muxer_element(codecfinder.containermap[containerchoice]) audiostatus = codecfinder.get_audio_encoder_element(codecfinder.codecmap[self.AudioCodec]) videostatus = codecfinder.get_video_encoder_element(codecfinder.codecmap[self.VideoCodec]) if not containerstatus or not videostatus or not audiostatus: fail_info = [] if containerstatus == False: fail_info.append(gst.caps_from_string(codecfinder.containermap[containerchoice])) if audiostatus == False: fail_info.append(gst.caps_from_string(codecfinder.codecmap[self.AudioCodec])) if videostatus == False: fail_info.append(gst.caps_from_string (codecfinder.codecmap[self.VideoCodec])) missing = [] for x in fail_info: missing.append(gst.pbutils.missing_encoder_installer_detail_new(x)) context = gst.pbutils.InstallPluginsContext () gst.pbutils.install_plugins_async (missing, context, self.donemessage, "") else: self._start_transcoding()