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
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 \

View file

@ -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']

View file

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