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


Python ffmpeg.output方法代码示例

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


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

示例1: test_node_repr

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_node_repr():
    in_file = ffmpeg.input('dummy.mp4')
    trim1 = ffmpeg.trim(in_file, start_frame=10, end_frame=20)
    trim2 = ffmpeg.trim(in_file, start_frame=30, end_frame=40)
    trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
    concatted = ffmpeg.concat(trim1, trim2, trim3)
    output = ffmpeg.output(concatted, 'dummy2.mp4')
    assert repr(in_file.node) == 'input(filename={!r}) <{}>'.format(
        'dummy.mp4', in_file.node.short_hash
    )
    assert repr(trim1.node) == 'trim(end_frame=20, start_frame=10) <{}>'.format(
        trim1.node.short_hash
    )
    assert repr(trim2.node) == 'trim(end_frame=40, start_frame=30) <{}>'.format(
        trim2.node.short_hash
    )
    assert repr(trim3.node) == 'trim(end_frame=60, start_frame=50) <{}>'.format(
        trim3.node.short_hash
    )
    assert repr(concatted.node) == 'concat(n=3) <{}>'.format(concatted.node.short_hash)
    assert repr(output.node) == 'output(filename={!r}) <{}>'.format(
        'dummy2.mp4', output.node.short_hash
    ) 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:25,代码来源:test_ffmpeg.py

示例2: _get_complex_filter_example

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def _get_complex_filter_example():
    split = ffmpeg.input(TEST_INPUT_FILE1).vflip().split()
    split0 = split[0]
    split1 = split[1]

    overlay_file = ffmpeg.input(TEST_OVERLAY_FILE)
    overlay_file = ffmpeg.crop(overlay_file, 10, 10, 158, 112)
    return (
        ffmpeg.concat(
            split0.trim(start_frame=10, end_frame=20),
            split1.trim(start_frame=30, end_frame=40),
        )
        .overlay(overlay_file.hflip())
        .drawbox(50, 50, 120, 120, color='red', thickness=5)
        .output(TEST_OUTPUT_FILE1)
        .overwrite_output()
    ) 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:19,代码来源:test_ffmpeg.py

示例3: test_filter_with_selector

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_filter_with_selector(use_shorthand):
    i = ffmpeg.input(TEST_INPUT_FILE1)
    if use_shorthand:
        v1 = i.video.hflip()
        a1 = i.audio.filter('aecho', 0.8, 0.9, 1000, 0.3)
    else:
        v1 = i['v'].hflip()
        a1 = i['a'].filter('aecho', 0.8, 0.9, 1000, 0.3)
    out = ffmpeg.output(a1, v1, TEST_OUTPUT_FILE1)
    assert out.get_args() == [
        '-i',
        TEST_INPUT_FILE1,
        '-filter_complex',
        '[0:a]aecho=0.8:0.9:1000:0.3[s0];' '[0:v]hflip[s1]',
        '-map',
        '[s0]',
        '-map',
        '[s1]',
        TEST_OUTPUT_FILE1,
    ] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:22,代码来源:test_ffmpeg.py

示例4: test_filter_concat__audio_video

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_filter_concat__audio_video():
    in1 = ffmpeg.input('in1.mp4')
    in2 = ffmpeg.input('in2.mp4')
    joined = ffmpeg.concat(in1.video, in1.audio, in2.hflip(), in2['a'], v=1, a=1).node
    args = ffmpeg.output(joined[0], joined[1], 'out.mp4').get_args()
    assert args == [
        '-i',
        'in1.mp4',
        '-i',
        'in2.mp4',
        '-filter_complex',
        '[1]hflip[s0];[0:v][0:a][s0][1:a]concat=a=1:n=2:v=1[s1][s2]',
        '-map',
        '[s1]',
        '-map',
        '[s2]',
        'out.mp4',
    ] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:20,代码来源:test_ffmpeg.py

示例5: test__run__error

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [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

示例6: test_multi_passthrough

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_multi_passthrough():
    out1 = ffmpeg.input('in1.mp4').output('out1.mp4')
    out2 = ffmpeg.input('in2.mp4').output('out2.mp4')
    out = ffmpeg.merge_outputs(out1, out2)
    assert ffmpeg.get_args(out) == [
        '-i',
        'in1.mp4',
        '-i',
        'in2.mp4',
        'out1.mp4',
        '-map',
        '1',
        'out2.mp4',
    ]
    assert ffmpeg.get_args([out1, out2]) == [
        '-i',
        'in2.mp4',
        '-i',
        'in1.mp4',
        'out2.mp4',
        '-map',
        '1',
        'out1.mp4',
    ] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:26,代码来源:test_ffmpeg.py

示例7: generate_thumbnail

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def generate_thumbnail(movie_path):
    """
    Generate a thumbnail to represent the movie given at movie path. It
    takes a picture at the first frame of the movie.
    """
    folder_path = os.path.dirname(movie_path)
    file_source_name = os.path.basename(movie_path)
    file_target_name = "%s.png" % file_source_name[:-4]
    file_target_path = os.path.join(folder_path, file_target_name)

    ffmpeg.input(movie_path, ss="00:00:00").output(
        file_target_path, vframes=1
    ).run(quiet=True)
    return file_target_path 
开发者ID:cgwire,项目名称:zou,代码行数:16,代码来源:movie_utils.py

示例8: build_playlist_movie

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def build_playlist_movie(
    tmp_file_paths, movie_file_path, width=None, height=1080, fps="24.00"
):
    """
    Build a single movie file from a playlist.
    """
    in_files = []
    if len(tmp_file_paths) > 0:
        (first_movie_file_path, _) = tmp_file_paths[0]
        if width is None:
            (width, height) = get_movie_size(first_movie_file_path)

        for tmp_file_path, file_name in tmp_file_paths:
            if not has_soundtrack(tmp_file_path):
                add_empty_soundtrack(tmp_file_path)

        for tmp_file_path, file_name in tmp_file_paths:
            in_file = ffmpeg.input(tmp_file_path)
            in_files.append(
                in_file["v"]
                .filter("setsar", "1/1")
                .filter("scale", width, height)
            )
            in_files.append(in_file["a"])

        joined = ffmpeg.concat(*in_files, v=1, a=1).node
        video = joined[0]
        audio = joined[1]

        try:
            ffmpeg.output(
                audio, video, movie_file_path
            ).overwrite_output().run()
        except Exception as e:
            print(e)
            return {"success": False, "message": str(e)}
    return {"success": True} 
开发者ID:cgwire,项目名称:zou,代码行数:39,代码来源:movie_utils.py

示例9: play

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def play(filename, strategy=None, output=None, play_audio=False):
    """
    Play or export a video from a file by default using ascii chars in terminal
    """
    engine = ve.VideoEngine()
    engine.load_video_from_file(filename)
    if  play_audio:
        import ffmpeg
        temp_dir = tempfile.gettempdir()
        temp_file_path = temp_dir + "/temp-audiofile-for-vta.wav"
        stream = ffmpeg.input(filename)
        stream = ffmpeg.output(stream, temp_file_path)
        stream = ffmpeg.overwrite_output(stream)
        ffmpeg.run(stream)
        engine.with_audio = True
    if strategy is not None:
        engine.set_strategy(strategy)
    engine.play(output) 
开发者ID:joelibaceta,项目名称:video-to-ascii,代码行数:20,代码来源:player.py

示例10: test_fluent_output

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_fluent_output():
    ffmpeg.input('dummy.mp4').trim(start_frame=10, end_frame=20).output('dummy2.mp4') 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:4,代码来源:test_ffmpeg.py

示例11: test_fluent_complex_filter

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_fluent_complex_filter():
    in_file = ffmpeg.input('dummy.mp4')
    return ffmpeg.concat(
        in_file.trim(start_frame=10, end_frame=20),
        in_file.trim(start_frame=30, end_frame=40),
        in_file.trim(start_frame=50, end_frame=60),
    ).output('dummy2.mp4') 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:9,代码来源:test_ffmpeg.py

示例12: test_repeated_args

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_repeated_args():
    out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4', streamid=['0:0x101', '1:0x102'])
    assert out_file.get_args() == ['-i', 'dummy.mp4', '-streamid', '0:0x101', '-streamid', '1:0x102', 'dummy2.mp4'] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:5,代码来源:test_ffmpeg.py

示例13: test__get_args__simple

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test__get_args__simple():
    out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4')
    assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4'] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:5,代码来源:test_ffmpeg.py

示例14: _get_simple_example

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def _get_simple_example():
    return ffmpeg.input(TEST_INPUT_FILE1).output(TEST_OUTPUT_FILE1) 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:4,代码来源:test_ffmpeg.py

示例15: test_combined_output

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import output [as 别名]
def test_combined_output():
    i1 = ffmpeg.input(TEST_INPUT_FILE1)
    i2 = ffmpeg.input(TEST_OVERLAY_FILE)
    out = ffmpeg.output(i1, i2, TEST_OUTPUT_FILE1)
    assert out.get_args() == [
        '-i',
        TEST_INPUT_FILE1,
        '-i',
        TEST_OVERLAY_FILE,
        '-map',
        '0',
        '-map',
        '1',
        TEST_OUTPUT_FILE1,
    ] 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:17,代码来源:test_ffmpeg.py


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