当前位置: 首页>>代码示例>>Python>>正文


Python ffmpeg.Error方法代码示例

本文整理汇总了Python中ffmpeg.Error方法的典型用法代码示例。如果您正苦于以下问题:Python ffmpeg.Error方法的具体用法?Python ffmpeg.Error怎么用?Python ffmpeg.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ffmpeg的用法示例。


在下文中一共展示了ffmpeg.Error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test__run__error

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def test__run__error(mocker, capture_stdout, capture_stderr):
    mocker.patch.object(ffmpeg._run, 'compile', return_value=['ffmpeg'])
    stream = _get_complex_filter_example()
    with pytest.raises(ffmpeg.Error) as excinfo:
        out, err = ffmpeg.run(
            stream, capture_stdout=capture_stdout, capture_stderr=capture_stderr
        )
    assert str(excinfo.value) == 'ffmpeg error (see stderr output for detail)'
    out = excinfo.value.stdout
    err = excinfo.value.stderr
    if capture_stdout:
        assert out == ''.encode()
    else:
        assert out is None
    if capture_stderr:
        assert err.decode().startswith('ffmpeg version')
    else:
        assert err is None 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:20,代码来源:test_ffmpeg.py

示例2: decode_audio

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def decode_audio(in_filename, **input_kwargs):
    try:
        out, err = (ffmpeg
            .input(in_filename, **input_kwargs)
            .output('-', format='s16le', acodec='pcm_s16le', ac=1, ar='16k')
            .overwrite_output()
            .run(capture_stdout=True, capture_stderr=True)
        )
    except ffmpeg.Error as e:
        print(e.stderr, file=sys.stderr)
        sys.exit(1)
    return out 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:14,代码来源:transcribe.py

示例3: generate_thumbnail

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def generate_thumbnail(in_filename, out_filename, time, width):
    try:
        (
            ffmpeg
            .input(in_filename, ss=time)
            .filter('scale', width, -1)
            .output(out_filename, vframes=1)
            .overwrite_output()
            .run(capture_stdout=True, capture_stderr=True)
        )
    except ffmpeg.Error as e:
        print(e.stderr.decode(), file=sys.stderr)
        sys.exit(1) 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:15,代码来源:get_video_thumbnail.py

示例4: test__probe__exception

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def test__probe__exception():
    with pytest.raises(ffmpeg.Error) as excinfo:
        ffmpeg.probe(BOGUS_INPUT_FILE)
    assert str(excinfo.value) == 'ffprobe error (see stderr output for detail)'
    assert 'No such file or directory'.encode() in excinfo.value.stderr 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:7,代码来源:test_ffmpeg.py

示例5: normalize_movie

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def normalize_movie(movie_path, fps="24.00", width=None, height=1080):
    """
    Turn movie in a 1080p movie file (or use resolution given in parameter).
    """
    folder_path = os.path.dirname(movie_path)
    file_source_name = os.path.basename(movie_path)
    file_target_name = "%s.mp4" % file_source_name[:-8]
    file_target_path = os.path.join(folder_path, file_target_name)

    (w, h) = get_movie_size(movie_path)
    resize_factor = w / h

    if width is None:
        width = math.floor(resize_factor * height)

    if width % 2 == 1:
        width = width + 1

    if height % 2 == 1:
        height = height + 1

    try:
        stream = ffmpeg.input(movie_path)
        stream = stream.output(
            file_target_path,
            pix_fmt="yuv420p",
            format="mp4",
            r=fps,
            crf="15",
            preset="medium",
            vcodec="libx264",
            s="%sx%s" % (width, height),
        )
        stream.run(quiet=False, capture_stderr=True)
        if not has_soundtrack(file_target_path):
            add_empty_soundtrack(file_target_path)
    except ffmpeg.Error as exc:
        from flask import current_app

        current_app.logger.error(exc.stderr)
        raise

    return file_target_path 
开发者ID:cgwire,项目名称:zou,代码行数:45,代码来源:movie_utils.py

示例6: check_file

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import Error [as 别名]
def check_file(filename, error_detect='default', strict_level=0, zero_detect=0, ffmpeg_threads=0):
    if sys.version_info[0] < 3:
        filename = filename.decode('utf8')

    file_lowercase = filename.lower()
    file_ext = os.path.splitext(file_lowercase)[1][1:]

    file_size = 'NA'

    try:
        file_size = check_size(filename)
        if zero_detect > 0:
            check_zeros(filename, CONFIG.zero_detect)

        if file_ext in PIL_EXTENSIONS:
            if strict_level in [1, 2]:
                pil_check(filename)
            if strict_level in [0, 2]:
                magick_identify_check(filename)

        if file_ext in PDF_EXTENSIONS:
            if strict_level in [1, 2]:
                pypdf_check(filename)
            if strict_level in [0, 2]:
                magick_identify_check(filename)

        if file_ext in MAGICK_EXTENSIONS:
            if strict_level in [1, 2]:
                magick_check(filename)
            if strict_level in [0, 2]:
                magick_identify_check(filename)

        if file_ext in VIDEO_EXTENSIONS:
            ffmpeg_check(filename, error_detect=error_detect, threads=ffmpeg_threads)

    # except ffmpeg.Error as e:
    #     # print e.stderr
    #     return False, (filename, str(e), file_size)
    except Exception as e:
        # IMHO "Exception" is NOT too broad, io/decode/any problem should be (with details) an image problem
        return False, (filename, str(e), file_size)

    return True, (filename, None, file_size) 
开发者ID:ftarlao,项目名称:check-media-integrity,代码行数:45,代码来源:check_mi.py


注:本文中的ffmpeg.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。