def modify_property_Bitrate(self, value): if not self.checkPropertyType('bitrate', value, int): return False maxsamplerate = get_max_sample_rate(value, self.channels) if self.rate > maxsamplerate: self.warning("Could not set property 'bitrate' on the theora " "encoder: rate %d > max rate %d (for %d kbit/sec)" % (self.rate, maxsamplerate, value)) return False self.modify_element_property('enc', 'bitrate', value, needs_reset=True) return True
def modify_property_Bitrate(self, value): if not self.checkPropertyType('bitrate', value, int): return False maxsamplerate = get_max_sample_rate(value, self.channels) if self.rate > maxsamplerate: self.warning("Could not set property 'bitrate' on the theora " "encoder: rate %d > max rate %d (for %d kbit/sec)" % ( self.rate, maxsamplerate, value)) return False self.modify_element_property('enc', 'bitrate', value, needs_reset=True) return True
def buffer_probe(pad, buffer, unused_user_data): # this comes from another thread caps = pad.query_caps(None).to_string() kaps = Gst.structure_from_string(caps) in_rate = 44100 # kaps[0].get_value('rate') # now do necessary filtercaps self.rate = in_rate if self.bitrate > -1: maxsamplerate = get_max_sample_rate(self.bitrate, self.channels) if in_rate > maxsamplerate: self.rate = get_preferred_sample_rate(maxsamplerate) self.debug( "rate %d > max rate %d (for %d kbit/sec), " "selecting rate %d instead" % (in_rate, maxsamplerate, self.bitrate, self.rate) ) caps_str = "audio/x-raw, rate=%d, channels=%d" % (self.rate, self.channels) cf.set_property("caps", Gst.caps_from_string(caps_str)) pad.remove_probe(handle) return True
def buffer_probe(pad, buffer): # this comes from another thread caps = buffer.get_caps() in_rate = caps[0]['rate'] # now do necessary filtercaps self.rate = in_rate if self.bitrate > -1: maxsamplerate = get_max_sample_rate(self.bitrate, self.channels) if in_rate > maxsamplerate: self.rate = get_preferred_sample_rate(maxsamplerate) self.debug( 'rate %d > max rate %d (for %d kbit/sec), ' 'selecting rate %d instead' % (in_rate, maxsamplerate, self.bitrate, self.rate)) caps_str = 'audio/x-raw-float, rate=%d, channels=%d' % ( self.rate, self.channels) cf.set_property('caps', gst.caps_from_string(caps_str)) pad.remove_buffer_probe(handle) return True
def buffer_probe(pad, buffer): # this comes from another thread caps = buffer.get_caps() in_rate = caps[0]['rate'] # now do necessary filtercaps rate = in_rate if self.bitrate > -1: maxsamplerate = get_max_sample_rate( self.bitrate, self.channels) if in_rate > maxsamplerate: rate = get_preferred_sample_rate(maxsamplerate) self.debug( 'rate %d > max rate %d (for %d kbit/sec), ' 'selecting rate %d instead' % ( in_rate, maxsamplerate, self.bitrate, rate)) caps_str = 'audio/x-raw-float, rate=%d, channels=%d' % (rate, self.channels) cf.set_property('caps', gst.caps_from_string(caps_str)) pad.remove_buffer_probe(handle) return True
def buffer_probe(pad, buffer, user_data): # this comes from another thread caps = pad.get_current_caps() in_rate = caps.get_structure(0).get_int('rate')[1] # now do necessary filtercaps self.rate = in_rate if self.bitrate > -1: maxsamplerate = get_max_sample_rate( self.bitrate, self.channels) if in_rate > maxsamplerate: self.rate = get_preferred_sample_rate(maxsamplerate) self.debug( 'rate %d > max rate %d (for %d kbit/sec), ' 'selecting rate %d instead' % ( in_rate, maxsamplerate, self.bitrate, self.rate)) caps_str = 'audio/x-raw, rate=%d, channels=%d' % (self.rate, self.channels) cf.set_property('caps', Gst.Caps.from_string(caps_str)) pad.remove_probe(handle) return True