def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.AUDIO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) self.pipeline = None self._wavebin = None self.discovered = False self.ges_elem = ges_elem asset = self.ges_elem.get_parent().get_asset() self.n_samples = asset.get_duration() / SAMPLE_DURATION self.samples = None self.peaks = None self._start = 0 self._end = 0 self._surface_x = 0 # Guard against malformed URIs self.wavefile = None self._uri = quote_uri(get_proxy_target(ges_elem).props.id) self._num_failures = 0 self.adapter = None self.surface = None self._force_redraw = True self.ges_elem.connect("notify::in-point", self._inpoint_changed_cb) self.connect("notify::height-request", self._height_changed_cb) self.become_controlled()
def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.AUDIO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) self.pipeline = None self._wavebin = None self.discovered = False self.ges_elem = ges_elem self.timeline = ges_elem.get_parent().get_timeline().ui asset = self.ges_elem.get_parent().get_asset() self.n_samples = asset.get_duration() / SAMPLE_DURATION self.samples = None self.peaks = None self._start = 0 self._end = 0 self._surface_x = 0 # Guard against malformed URIs self.wavefile = None self._uri = quote_uri(get_proxy_target(ges_elem).props.id) self._num_failures = 0 self.adapter = None self.surface = None self._force_redraw = True self.ges_elem.connect("notify::in-point", self._inpoint_changed_cb) self.connect("notify::height-request", self._height_changed_cb) self.becomeControlled()
def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.AUDIO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) self.pipeline = None self._wavebin = None self.ges_elem = ges_elem self.samples = None self.peaks = None self.surface = None # The zoom level when self.surface has been created. self._surface_zoom_level = 0 # The samples range used when self.surface has been created. self._surface_start_ns = 0 self._surface_end_ns = 0 # Guard against malformed URIs self.wavefile = None self._uri = quote_uri(get_proxy_target(ges_elem).props.id) self._num_failures = 0 self.become_controlled()
def info_name(info): """Returns a human-readable filename (without the path and quoting). Args: info (GES.Asset or DiscovererInfo): The info to display. """ if isinstance(info, GES.Asset): filename = urllib.parse.unquote(os.path.basename(get_proxy_target(info).get_id())) elif isinstance(info, DiscovererInfo): filename = urllib.parse.unquote(os.path.basename(info.get_uri())) else: raise Exception("Unsupported argument type: %s" % type(info)) return GLib.markup_escape_text(filename)
def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.VIDEO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) # Variables related to the timeline objects self.timeline = ges_elem.get_parent().get_timeline().ui self.ges_elem = ges_elem # Guard against malformed URIs self.uri = quote_uri(get_proxy_target(ges_elem).props.id) self.__preroll_timeout_id = 0 # Variables related to thumbnailing self.wishlist = [] self.queue = [] self._thumb_cb_id = None self._running = False # We should have one thumbnail per thumb_period. # TODO: get this from the user settings self.thumb_period = int(0.5 * Gst.SECOND) self.thumb_height = THUMB_HEIGHT self.__image_pixbuf = None if isinstance(ges_elem, GES.ImageSource): self.__image_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( Gst.uri_get_location(self.uri), -1, self.thumb_height, True) self.thumbs = {} self.thumb_cache = ThumbnailCache.get(self.uri) self._ensure_proxy_thumbnails_cache() self.thumb_width, unused_height = self.thumb_cache.getImagesSize() self.cpu_usage_tracker = CPUUsageTracker() self.interval = 500 # Every 0.5 second, reevaluate the situation # Connect signals and fire things up self.ges_elem.connect("notify::in-point", self._inpoint_changed_cb) self.pipeline = None self.gdkpixbufsink = None self.becomeControlled() self.connect("notify::height-request", self._height_changed_cb)
def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.VIDEO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) self.ges_elem = ges_elem # Guard against malformed URIs self.uri = quote_uri(get_proxy_target(ges_elem).props.id) self.__start_id = 0 self.__preroll_timeout_id = 0 self._thumb_cb_id = 0 # The thumbs to be generated. self.queue = [] # The position for which a thumbnail is currently being generated. self.position = -1 # The positions for which we failed to get a pixbuf. self.failures = set() self._thumb_cb_id = None self.thumbs = {} self.thumb_height = THUMB_HEIGHT self.thumb_width = 0 self.__image_pixbuf = None if not isinstance(ges_elem, GES.ImageSource): self.thumb_cache = ThumbnailCache.get(self.uri) self._ensure_proxy_thumbnails_cache() self.thumb_width, unused_height = self.thumb_cache.image_size self.pipeline = None self.gdkpixbufsink = None self.cpu_usage_tracker = CPUUsageTracker() # Initial delay before generating the next thumbnail, in millis. self.interval = 500 # Connect signals and fire things up self.ges_elem.connect("notify::in-point", self._inpoint_changed_cb) self.ges_elem.connect("notify::duration", self._duration_changed_cb) self.become_controlled() self.connect("notify::height-request", self._height_changed_cb)
def beautify_asset(asset): """Formats the specified asset for display. Args: asset (GES.Asset): The asset to display. """ from pitivi.utils.proxy import get_proxy_target uri = get_proxy_target(asset).props.id path = path_from_uri(uri) res = ["<b>" + GLib.markup_escape_text(path) + "</b>"] ranks = { DiscovererVideoInfo: 0, DiscovererAudioInfo: 1, DiscovererStreamInfo: 2 } def stream_sort_key(stream): try: return ranks[type(stream)] except KeyError: return len(ranks) info = asset.get_info() streams = info.get_stream_list() streams.sort(key=stream_sort_key) for stream in streams: try: beautified_string = beautify_stream(stream) except NotImplementedError: do_log(ERROR, "Beautify", "None", "Cannot beautify %s", stream) continue if beautified_string: res.append(beautified_string) duration = beautify_length(asset.get_duration()) if duration: res.append(_("<b>Duration:</b> %s") % duration) if asset.creation_progress < 100: res.append( _("<b>Proxy creation progress:</b> %d%%") % asset.creation_progress) return "\n".join(res)
def beautify_asset(asset): """Formats the specified asset for display. Args: asset (GES.Asset): The asset to display. """ uri = get_proxy_target(asset).props.id path = path_from_uri(uri) res = ["<b>" + GLib.markup_escape_text(path) + "</b>"] ranks = { DiscovererVideoInfo: 0, DiscovererAudioInfo: 1, DiscovererStreamInfo: 2 } def stream_sort_key(stream): try: return ranks[type(stream)] except KeyError: return len(ranks) info = asset.get_info() streams = info.get_stream_list() streams.sort(key=stream_sort_key) for stream in streams: try: beautified_string = beautify_stream(stream) except NotImplementedError: doLog(ERROR, "Beautify", "None", "Cannot beautify %s", stream) continue if beautified_string: res.append(beautified_string) duration = beautify_length(asset.get_duration()) if duration: res.append(_("<b>Duration:</b> %s") % duration) if asset.creation_progress < 100: res.append(_("<b>Proxy creation progress:</b> %d%%") % asset.creation_progress) return "\n".join(res)
def get(cls, obj): """Gets a ThumbnailCache for the specified object. Args: obj (str or GES.UriClipAsset): The object for which to get a cache, it can be a string representing a URI, or a GES.UriClipAsset. Returns: ThumbnailCache: The cache for the object. """ if isinstance(obj, str): uri = obj elif isinstance(obj, GES.UriClipAsset): uri = get_proxy_target(obj).props.id else: raise ValueError("Unhandled type: %s" % type(obj)) if uri not in cls.caches_by_uri: cls.caches_by_uri[uri] = ThumbnailCache(uri) return cls.caches_by_uri[uri]
def __init__(self, ges_elem, max_cpu_usage): Previewer.__init__(self, GES.TrackType.VIDEO, max_cpu_usage) Zoomable.__init__(self) Loggable.__init__(self) self.ges_elem = ges_elem # Guard against malformed URIs self.uri = quote_uri(get_proxy_target(ges_elem).props.id) self.__start_id = 0 self.__image_pixbuf = None self.thumbs = {} self.thumb_height = THUMB_HEIGHT self.thumb_width = 0 self.ges_elem.connect("notify::duration", self._duration_changed_cb) self.become_controlled() self.connect("notify::height-request", self._height_changed_cb)