use ffmpeg > 2.1 for mp4 frames if settings.FFMPEG is defined, fixes #2549

This commit is contained in:
j 2014-11-16 20:34:55 +00:00
parent a8c1b8385a
commit bf6c12ae0f
3 changed files with 10 additions and 23 deletions

View file

@ -355,8 +355,8 @@ def frame(video, frame, position, height=128, redo=False, info=None):
if redo or not exists(frame): if redo or not exists(frame):
ox.makedirs(folder) ox.makedirs(folder)
if video.endswith('.mp4'): if video.endswith('.mp4'):
if settings.USE_MELT: if settings.FFMPEG:
cmd = melt_frame_cmd(video, frame, position, height, info) cmd = ffmpeg_frame_cmd(video, frame, position, height)
else: else:
cmd = avconv_frame_cmd(video, frame, position, height) cmd = avconv_frame_cmd(video, frame, position, height)
else: else:
@ -377,27 +377,15 @@ def avconv_frame_cmd(video, frame, position, height=128):
cmd += [frame] cmd += [frame]
return cmd return cmd
def melt_frame_cmd(video, frame, position, height=128, info=None): def ffmpeg_frame_cmd(video, frame, position, height=128):
if not info:
info = ox.avinfo(video)
fps = float(AspectRatio(info['video'][0]['framerate']))
position = int(position * fps)
format = frame.split('.')[-1]
vcodec = 'mjpeg' if format == 'jpg' else 'png'
cmd = [ cmd = [
'melt', settings.FFMPEG, '-y',
'-silent', '-ss', str(position),
video, '-i', video,
'in=%d' % position, 'out=%d' % position, '-an', '-frames:v', '1',
'-consumer', 'avformat:%s' % frame, '-vf', 'scale=-1:%s' % height,
'vcodec=%s' % vcodec, frame
'progressive=1'
] ]
if height:
dar = AspectRatio(info['video'][0]['display_aspect_ratio'])
width = int(dar * height)
width += width % 2
cmd += ['s=%sx%s' % (width, height)]
return cmd return cmd
def frame_direct(video, target, position): def frame_direct(video, target, position):

View file

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

View file

@ -67,7 +67,6 @@ apt-get install -y \
$LIBAVCODEC_EXTRA \ $LIBAVCODEC_EXTRA \
libav-tools \ libav-tools \
ffmpeg2theora \ ffmpeg2theora \
melt \
mkvtoolnix \ mkvtoolnix \
gpac \ gpac \
imagemagick \ imagemagick \