From f0a5f5ddb7ad93a2056f2982829dd89dee990fe7 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 16 Jul 2014 11:04:52 +0000 Subject: [PATCH] check for avconv version and use new command line api if needed (to support Ubuntu 14.04) --- pandora/app/config.py | 3 ++- pandora/archive/extract.py | 50 ++++++++++++++++++++++++-------------- pandora/settings.py | 1 + 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/pandora/app/config.py b/pandora/app/config.py index 772662034..c26ede1f1 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -16,7 +16,7 @@ from django.contrib.auth.models import User import ox.jsonc from ox.utils import json -from archive.extract import supported_formats, AVCONV +from archive.extract import supported_formats, AVCONV, avconv_version from item.utils import get_by_id @@ -142,6 +142,7 @@ check the README for further details. ''' % AVCONV) + settings.AVCONV_VERSION = avconv_version() settings.CONFIG = config admin = len(settings.CONFIG['userLevels']) - 1 if not 'syncdb' in sys.argv \ diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index a54548c03..a01b84d83 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -62,6 +62,13 @@ def supported_formats(): 'mp4': 'libx264' in stdout and 'libvo_aacenc' in stdout, } +def avconv_version(): + p = subprocess.Popen([AVCONV], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + version = stderr.split(' ')[2].split('-')[0] + return version + def stream(video, target, profile, info, avconv=None): if not os.path.exists(target): ox.makedirs(os.path.dirname(target)) @@ -198,24 +205,31 @@ def stream(video, target, profile, info, avconv=None): '-qdiff', '4' ] ''' - video_settings += [ - '-vcodec', 'libx264', - '-flags', '+loop+mv4', - '-cmp', '256', - '-partitions', '+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8', - '-me_method', 'hex', - '-subq', '7', - '-trellis', '1', - '-refs', '5', - '-bf', '0', - '-flags2', '+mixed_refs', - '-coder', '0', - '-me_range', '16', - '-sc_threshold', '40', - '-i_qfactor', '0.71', - '-qmin', '10', '-qmax', '51', - '-qdiff', '4' - ] + if settings.AVCONV_VERSION >= '9': + video_settings += [ + '-vcodec', 'libx264', + '-preset:v', 'medium', + '-profile:v', 'baseline', + ] + else: + video_settings += [ + '-vcodec', 'libx264', + '-flags', '+loop+mv4', + '-cmp', '256', + '-partitions', '+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8', + '-me_method', 'hex', + '-subq', '7', + '-trellis', '1', + '-refs', '5', + '-bf', '0', + '-flags2', '+mixed_refs', + '-coder', '0', + '-me_range', '16', + '-sc_threshold', '40', + '-i_qfactor', '0.71', + '-qmin', '10', '-qmax', '51', + '-qdiff', '4' + ] else: video_settings = ['-vn'] diff --git a/pandora/settings.py b/pandora/settings.py index b6d798e93..374fbfb49 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -151,6 +151,7 @@ LOGGING = { AUTH_PROFILE_MODULE = 'user.UserProfile' AUTH_CHECK_USERNAME = True +AVCONV_VERSION = 0 #========================================================================= #Pan.do/ra related settings settings