diff options
author | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-13 12:13:47 -0500 |
---|---|---|
committer | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-13 12:13:47 -0500 |
commit | b589c856a1bc83c9820e5955edd5a8ce977a5720 (patch) | |
tree | 0a94024dcfb6fe25aa2f42079f77fc4e1d42ac8d /lvc/video.py | |
parent | ea73322a4b9af2cb4288eb062641d7a596dbeeb6 (diff) | |
download | librevideoconverter-b589c856a1bc83c9820e5955edd5a8ce977a5720.tar.lz librevideoconverter-b589c856a1bc83c9820e5955edd5a8ce977a5720.tar.xz librevideoconverter-b589c856a1bc83c9820e5955edd5a8ce977a5720.zip |
pep8 en lvc/video.py
Diffstat (limited to 'lvc/video.py')
-rw-r--r-- | lvc/video.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lvc/video.py b/lvc/video.py index 81283be..caa9ded 100644 --- a/lvc/video.py +++ b/lvc/video.py @@ -11,6 +11,7 @@ from lvc.utils import hms_to_seconds, convert_path_for_subprocess logger = logging.getLogger(__name__) + class VideoFile(object): def __init__(self, filename): self.filename = filename @@ -59,6 +60,7 @@ class VideoFile(object): return self.thumbnails.get(key) + class Node(object): def __init__(self, line="", children=None): self.line = line @@ -179,8 +181,9 @@ def extract_info(ast): compatible_brands_node = metadata.get_by_key("compatible_brands") if compatible_brands_node: line = compatible_brands_node.line.split(':')[1].strip() - extra_container_types.extend(line[i:i+4] for i in range(0, len(line), 4) - if line[i:i+4] != major_brand) + extra_container_types.extend(line[i:i + 4] + for i in range(0, len(line), 4) + if line[i:i + 4] != major_brand) if extra_container_types: if not isinstance(info['container'], list): @@ -198,7 +201,7 @@ def extract_info(ast): except ValueError: if duration_string.strip() != "N/A": logging.warn("Error parsing duration string: %r", - duration_string) + duration_string) else: info['duration'] = hms_to_seconds(hours, minutes, seconds) for stream_node in duration.children: @@ -225,6 +228,7 @@ def extract_info(ast): info['audio_codec'] = audio_codec return info + def get_ffmpeg_output(filepath): commandline = [get_ffmpeg_executable_path(), @@ -232,16 +236,17 @@ def get_ffmpeg_output(filepath): logging.info("get_ffmpeg_output(): running %s", commandline) try: output = execute.check_output(commandline) - except execute.CalledProcessError, e: + except execute.CalledProcessError as e: if e.returncode != 1: logger.exception("error calling %r\noutput:%s", commandline, - e.output) + e.output) # ffmpeg -i generally returns 1, so we ignore the exception and # just get the output. output = e.output return output + def get_media_info(filepath): """Takes a file path and returns a dict of information about this media file that it extracted from ffmpeg -i. @@ -258,19 +263,22 @@ def get_media_info(filepath): logger.info('get_media_info: %r', info) return info + def get_thumbnail(filename, width, height, output, completion, skip=0): name = 'Thumbnail - %r @ %sx%s' % (filename, width, height) + def run(): rv = get_thumbnail_synchronous(filename, width, height, output, skip) idle_add(lambda: completion(rv)) t = threading.Thread(target=run, name=name) t.start() + def get_thumbnail_synchronous(filename, width, height, output, skip=0): executable = get_ffmpeg_executable_path() filter_ = 'scale=%i:%i' % (width, height) # bz19571: temporary disable: libav ffmpeg does not support this filter - #if 'ffmpeg' in executable: + # if 'ffmpeg' in executable: # # supports the thumbnail filter, we hope # filter_ = 'thumbnail,' + filter_ commandline = [executable, @@ -279,7 +287,7 @@ def get_thumbnail_synchronous(filename, width, height, output, skip=0): '-vf', filter_, '-vframes', '1', output] try: execute.check_output(commandline) - except execute.CalledProcessError, e: + except execute.CalledProcessError as e: logger.exception('error calling %r\ncode:%s\noutput:%s', commandline, e.returncode, e.output) return None |