check for avconv version and use new command line api if needed (to support Ubuntu 14.04)

This commit is contained in:
j 2014-07-16 11:04:52 +00:00
parent f433495592
commit f0a5f5ddb7
3 changed files with 35 additions and 19 deletions

View file

@ -16,7 +16,7 @@ from django.contrib.auth.models import User
import ox.jsonc import ox.jsonc
from ox.utils import json 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 from item.utils import get_by_id
@ -142,6 +142,7 @@ check the README for further details.
''' % AVCONV) ''' % AVCONV)
settings.AVCONV_VERSION = avconv_version()
settings.CONFIG = config settings.CONFIG = config
admin = len(settings.CONFIG['userLevels']) - 1 admin = len(settings.CONFIG['userLevels']) - 1
if not 'syncdb' in sys.argv \ if not 'syncdb' in sys.argv \

View file

@ -62,6 +62,13 @@ def supported_formats():
'mp4': 'libx264' in stdout and 'libvo_aacenc' in stdout, '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): def stream(video, target, profile, info, avconv=None):
if not os.path.exists(target): if not os.path.exists(target):
ox.makedirs(os.path.dirname(target)) ox.makedirs(os.path.dirname(target))
@ -198,24 +205,31 @@ def stream(video, target, profile, info, avconv=None):
'-qdiff', '4' '-qdiff', '4'
] ]
''' '''
video_settings += [ if settings.AVCONV_VERSION >= '9':
'-vcodec', 'libx264', video_settings += [
'-flags', '+loop+mv4', '-vcodec', 'libx264',
'-cmp', '256', '-preset:v', 'medium',
'-partitions', '+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8', '-profile:v', 'baseline',
'-me_method', 'hex', ]
'-subq', '7', else:
'-trellis', '1', video_settings += [
'-refs', '5', '-vcodec', 'libx264',
'-bf', '0', '-flags', '+loop+mv4',
'-flags2', '+mixed_refs', '-cmp', '256',
'-coder', '0', '-partitions', '+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8',
'-me_range', '16', '-me_method', 'hex',
'-sc_threshold', '40', '-subq', '7',
'-i_qfactor', '0.71', '-trellis', '1',
'-qmin', '10', '-qmax', '51', '-refs', '5',
'-qdiff', '4' '-bf', '0',
] '-flags2', '+mixed_refs',
'-coder', '0',
'-me_range', '16',
'-sc_threshold', '40',
'-i_qfactor', '0.71',
'-qmin', '10', '-qmax', '51',
'-qdiff', '4'
]
else: else:
video_settings = ['-vn'] video_settings = ['-vn']

View file

@ -151,6 +151,7 @@ LOGGING = {
AUTH_PROFILE_MODULE = 'user.UserProfile' AUTH_PROFILE_MODULE = 'user.UserProfile'
AUTH_CHECK_USERNAME = True AUTH_CHECK_USERNAME = True
AVCONV_VERSION = 0
#========================================================================= #=========================================================================
#Pan.do/ra related settings settings #Pan.do/ra related settings settings