def __init__(self, path): os.stat(path) self.path = path self.playlist = os.path.join(path, self.PLAYLIST_FILE) os.stat(self.playlist) self.segments = fs.glob(os.path.join(path, SEGMENT_GLOB)) thumbnail = os.path.join(path, self.THUMBNAIL_FILE) if os.path.exists(thumbnail)): self.thumbnail = thumbnail
def make_thumbnail(stream, filename="thumb.jpg", clobber=False, **kwargs): outfile = os.path.join(stream, filename) if not clobber and os.path.exists(outfile): return (Processing.WILL_NOT_CLOBBER, outfile) segments = fs.glob(os.path.join(stream, "*.ts")) if not segments: raise ValueError("stream '%s' does not contain any segments" % stream) segment = random.choice(segments) dimensions = kwargs.get("dimensions", "240x135") try: process.check_output(["ffmpeg", "-i", segment, "-vframes", "1", "-an", "-s", dimensions, "-ss", "1", outfile]) return (Processing.COMPLETE, outfile) except process.CalledProcessError, e: raise ProcessingError(e.output)