Ejemplo n.º 1
0
def get_frame(video, when):
    # out = join(tmp_path, 'frame%s.png' % when)
    out = os.path.basename(video) + '.tmp_frame%f.png' % when
    cmd = ("ffmpeg -ss %s -i %s -y -f image2 -vframes 1 %s" % (when, video, out))    
    system_cmd_result(cwd='.', cmd=cmd,
                      display_stdout=False,
                      display_stderr=False,
                      raise_on_error=True,
                      capture_keyboard_interrupt=False)  # @UnusedVariable
    
    frame = imread(out)
    os.unlink(out)
    return frame
Ejemplo n.º 2
0
def get_x264_encoder_params(crf=18, preset='medium'):
    cmds = []
    cmds += ['-vcodec', 'libx264']
    # Let's detect ffmpeg version
    res = system_cmd_result('.', ['ffmpeg', '-version'])
    ffmpeg_version = res.stdout.split('\n')[0]
    
    # SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.3
    
    # if 'ubuntu0.10.04.3' in ffmpeg_version:
    if '0.5' in ffmpeg_version:  # or '0.8.6' in ffmpeg_version:
        cmds += ['-vpre', 'libx264-default']
    else:
        cmds += ['-preset', preset]

    cmds += ['-crf', '%d' % crf]
    return cmds
Ejemplo n.º 3
0
def get_x264_encoder_params(crf=18, preset='medium'):
    cmds = []
    cmds += ['-vcodec', 'libx264']
    # Let's detect ffmpeg version
    res = system_cmd_result('.', ['ffmpeg', '-version'])
    ffmpeg_version = res.stdout.split('\n')[0]

    # SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.3

    # if 'ubuntu0.10.04.3' in ffmpeg_version:
    if '0.5' in ffmpeg_version:  # or '0.8.6' in ffmpeg_version:
        cmds += ['-vpre', 'libx264-default']
    else:
        cmds += ['-preset', preset]

    cmds += ['-crf', '%d' % crf]
    return cmds
Ejemplo n.º 4
0
def get_x264_encoder_params(crf=18, preset="medium"):
    cmds = []
    cmds += ["-vcodec", "libx264"]
    # Let's detect ffmpeg version
    res = system_cmd_result(".", ["ffmpeg", "-version"])
    ffmpeg_version = res.stdout.split("\n")[0]

    # SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.3

    # if 'ubuntu0.10.04.3' in ffmpeg_version:
    if "0.5" in ffmpeg_version:  # or '0.8.6' in ffmpeg_version:
        cmds += ["-vpre", "libx264-default"]
    else:
        cmds += ["-preset", preset]

    cmds += ["-crf", "%d" % crf]
    return cmds