コード例 #1
0
 def make_thumb_ffmpeg(self):
     # get input dimensions
     try:
         dims = FFmpeg.get_dimensions(self.path)
     except Exception as ex:
         logger.error(str(ex))
         dims = {}
     if not dims:
         return None, 'JPEG', 0, 0
     width = dims['width']
     height = dims['height']
     if 'duration' in dims:
         duration = float(dims['duration'])
     else:
         duration = 0.0
     skip = int(min(duration / 2, 10.0))
     # target dimensions
     w, h = 160, 120
     if width < height:
         w, h = h, w
     # use ffmpeg to make scaled, padded, single frame JPEG
     quality = 1
     while True:
         try:
             data = FFmpeg.make_thumbnail(self.path, w, h, skip, quality)
         except Exception as ex:
             logger.error(str(ex))
             return None, 'JPEG', 0, 0
         if not data or len(data) < 50000:
             break
         quality += 1
     return data, 'JPEG', w, h
コード例 #2
0
ファイル: metadata.py プロジェクト: orensbruli/Photini
 def __init__(self, path):
     self._path = path
     self.md = {}
     raw = FFmpeg.ffprobe(path)
     if 'format' in raw and 'tags' in raw['format']:
         self.md.update(self.read_tags('format', raw['format']['tags']))
     if 'streams' in raw:
         for stream in raw['streams']:
             if 'tags' in stream:
                 self.md.update(
                     self.read_tags('stream[{}]'.format(stream['index']),
                                    stream['tags']))