forked from 0x2620/pandora
use avconv to extract frames from mp4 videos
This commit is contained in:
parent
9ac3342acd
commit
8917a71f47
1 changed files with 19 additions and 7 deletions
|
@ -278,20 +278,32 @@ def run_command(cmd, timeout=10):
|
||||||
return p.returncode
|
return p.returncode
|
||||||
|
|
||||||
|
|
||||||
def frame(videoFile, frame, position, height=128, redo=False):
|
def frame(video, frame, position, height=128, redo=False):
|
||||||
'''
|
'''
|
||||||
params:
|
params:
|
||||||
videoFile input
|
video input
|
||||||
frame output
|
frame output
|
||||||
position as float in seconds
|
position as float in seconds
|
||||||
height of frame
|
height of frame
|
||||||
redo boolean to extract file even if it exists
|
redo boolean to extract file even if it exists
|
||||||
'''
|
'''
|
||||||
if exists(videoFile):
|
if exists(video):
|
||||||
frameFolder = os.path.dirname(frame)
|
folder = os.path.dirname(frame)
|
||||||
if redo or not exists(frame):
|
if redo or not exists(frame):
|
||||||
ox.makedirs(frameFolder)
|
ox.makedirs(folder)
|
||||||
cmd = ['oxframe', '-i', videoFile, '-o', frame,
|
if video.endswith('.mp4'):
|
||||||
|
cmd = [
|
||||||
|
AVCONV, '-y',
|
||||||
|
'-ss', str(position),
|
||||||
|
'-i', video,
|
||||||
|
'-an', '-vframes', '1',
|
||||||
|
'-vf', 'scale=-1:%s' % height
|
||||||
|
]
|
||||||
|
if not frame.endswith('.png'):
|
||||||
|
cmd += ['-f', 'mjpeg']
|
||||||
|
cmd += [frame]
|
||||||
|
else:
|
||||||
|
cmd = ['oxframe', '-i', video, '-o', frame,
|
||||||
'-p', str(position), '-y', str(height)]
|
'-p', str(position), '-y', str(height)]
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue