當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。