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


Python ffmpeg.input方法代码示例

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


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

示例1: test_multi_passthrough

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

示例2: test_node_repr

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

示例3: _get_complex_filter_example

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

示例4: test_filter_with_selector

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

示例5: convert_to_mp3

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import input [as 别名]
def convert_to_mp3(path):
    """Covert to mp3 using the python ffmpeg module."""
    new_name = path + '_new.mp3'
    try:
        ffmpeg.input(path).output(
                            new_name,
                            loglevel='panic',
                            ar=44100,
                            ac=2,
                            ab='{}k'.format(defaults.DEFAULT.SONG_QUALITY),
                            f='mp3'
                        ).run()
        # Delete the temp file now
        remove(path)
        return new_name
    except ffmpeg._run.Error:
        # This error is usually thrown where ffmpeg doesn't have to
        # overwrite a file.
        # The bug is from ffmpeg, I'm just adding this catch to
        # handle that.
        return new_name 
开发者ID:deepjyoti30,项目名称:ytmdl,代码行数:23,代码来源:utility.py

示例6: test_repeated_args

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

示例7: generate_thumbnail

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

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import input [as 别名]
def ffmpeg_check(filename, error_detect='default', threads=0):
    if error_detect == 'default':
        stream = ffmpeg.input(filename)
    else:
        if error_detect == 'strict':
            custom = '+crccheck+bitstream+buffer+explode'
        else:
            custom = error_detect
        stream = ffmpeg.input(filename, **{'err_detect': custom, 'threads': threads})

    stream = stream.output('pipe:', format="null")
    stream.run(capture_stdout=True, capture_stderr=True) 
开发者ID:ftarlao,项目名称:check-media-integrity,代码行数:14,代码来源:check_mi.py

示例11: test_fluent_equality

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import input [as 别名]
def test_fluent_equality():
    base1 = ffmpeg.input('dummy1.mp4')
    base2 = ffmpeg.input('dummy1.mp4')
    base3 = ffmpeg.input('dummy2.mp4')
    t1 = base1.trim(start_frame=10, end_frame=20)
    t2 = base1.trim(start_frame=10, end_frame=20)
    t3 = base1.trim(start_frame=10, end_frame=30)
    t4 = base2.trim(start_frame=10, end_frame=20)
    t5 = base3.trim(start_frame=10, end_frame=20)
    assert t1 == t2
    assert t1 != t3
    assert t1 == t4
    assert t1 != t5 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:15,代码来源:test_ffmpeg.py

示例12: test_fluent_concat

# 需要导入模块: import ffmpeg [as 别名]
# 或者: from ffmpeg import input [as 别名]
def test_fluent_concat():
    base = ffmpeg.input('dummy.mp4')
    trimmed1 = base.trim(start_frame=10, end_frame=20)
    trimmed2 = base.trim(start_frame=30, end_frame=40)
    trimmed3 = base.trim(start_frame=50, end_frame=60)
    concat1 = ffmpeg.concat(trimmed1, trimmed2, trimmed3)
    concat2 = ffmpeg.concat(trimmed1, trimmed2, trimmed3)
    concat3 = ffmpeg.concat(trimmed1, trimmed3, trimmed2)
    assert concat1 == concat2
    assert concat1 != concat3 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:12,代码来源:test_ffmpeg.py

示例13: test_fluent_output

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

示例14: test_fluent_complex_filter

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

示例15: test__get_args__simple

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


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