Esempio n. 1
0
def load_sync(context, url, callback):
    # Disable storage of original. These lines are useful if
    # you want your Thumbor instance to store all originals persistently
    # except video frames.
    #
    # from thumbor.storages.no_storage import Storage as NoStorage
    # context.modules.storage = NoStorage(context)

    unquoted_url = unquote(url)

    command = BaseWikimediaEngine.wrap_command([
        context.config.FFPROBE_PATH,
        '-v',
        'error',
        '-show_entries',
        'format=duration',
        '-of',
        'default=noprint_wrappers=1:nokey=1',
        '%s%s' % (uri_scheme, unquoted_url)
    ], context)

    logger.debug('Command: %r' % command)

    process = Subprocess(command, stdout=Subprocess.STREAM)
    process.set_exit_callback(
        partial(
            _parse_time_status,
            context,
            unquoted_url,
            callback,
            process
        )
    )
Esempio n. 2
0
def _parse_time(context, url, callback, output):
    duration = float(output)
    unquoted_url = unquote(url)

    try:
        seek = int(context.request.page)
    except AttributeError:
        seek = duration / 2

    destination = NamedTemporaryFile(delete=False)

    command = BaseWikimediaEngine.wrap_command([
        context.config.FFMPEG_PATH,
        # Order is important, for fast seeking -ss has to come before -i
        # As explained on https://trac.ffmpeg.org/wiki/Seeking
        '-ss',
        '%d' % seek,
        '-i',
        '%s%s' % (uri_scheme, unquoted_url),
        '-y',
        '-vframes',
        '1',
        '-an',
        '-f',
        'image2',
        '-nostats',
        '-loglevel',
        'error',
        destination.name
    ], context)

    logger.debug('Command: %r' % command)

    process = Subprocess(command)
    process.set_exit_callback(
        partial(
            _process_output,
            callback,
            destination.name
        )
    )
Esempio n. 3
0
def load_sync(context, url, callback):
    # Disable storage of original. These lines are useful if
    # you want your Thumbor instance to store all originals persistently
    # except video frames.
    #
    # from thumbor.storages.no_storage import Storage as NoStorage
    # context.modules.storage = NoStorage(context)

    unquoted_url = unquote(url)

    command = BaseWikimediaEngine.wrap_command([
        context.config.FFPROBE_PATH, '-v', 'error', '-show_entries',
        'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1',
        '%s%s' % (uri_scheme, unquoted_url)
    ], context)

    logger.debug('Command: %r' % command)

    process = Subprocess(command, stdout=Subprocess.STREAM)
    process.set_exit_callback(
        partial(_parse_time_status, context, unquoted_url, callback, process))
Esempio n. 4
0
def _parse_time(context, url, callback, output):
    duration = float(output)
    unquoted_url = unquote(url)

    try:
        seek = int(context.request.page)
    except AttributeError:
        seek = duration / 2

    destination = NamedTemporaryFile(delete=False)

    command = BaseWikimediaEngine.wrap_command(
        [
            context.config.FFMPEG_PATH,
            # Order is important, for fast seeking -ss has to come before -i
            # As explained on https://trac.ffmpeg.org/wiki/Seeking
            '-ss',
            '%d' % seek,
            '-i',
            '%s%s' % (uri_scheme, unquoted_url),
            '-y',
            '-vframes',
            '1',
            '-an',
            '-f',
            'image2',
            '-nostats',
            '-loglevel',
            'error',
            destination.name
        ],
        context)

    logger.debug('Command: %r' % command)

    process = Subprocess(command)
    process.set_exit_callback(
        partial(_process_output, callback, destination.name))