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


Python ffmpy.FFmpeg方法代码示例

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


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

示例1: test_non_zero_exitcode_no_stderr

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_non_zero_exitcode_no_stderr():
    global_options = '--stdin none --stdout multiline --stderr none --exit-code 42'
    ff = FFmpeg(global_options=global_options)
    with pytest.raises(FFRuntimeError) as exc_info:
        ff.run(stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    assert exc_info.value.cmd == (
        "ffmpeg --stdin none --stdout multiline --stderr none --exit-code 42"
    )
    assert exc_info.value.exit_code == 42
    assert exc_info.value.stdout == b'These are\nmultiple lines\nprinted to stdout'
    assert exc_info.value.stderr == b''
    assert str(exc_info.value) == (
        "`ffmpeg --stdin none --stdout multiline --stderr none --exit-code 42` "
        'exited with status 42\n\n'
        'STDOUT:\n'
        'These are\n'
        'multiple lines\n'
        'printed to stdout\n\n'
        'STDERR:\n'
    ) 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:23,代码来源:test_cmd_execution.py

示例2: updateProfileVideoPicture

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def updateProfileVideoPicture(self, path):
        try:
            from ffmpy import FFmpeg
            files = {'file': open(path, 'rb')}
            data = {'params': self.genOBSParams({'oid': self.profile.mid,'ver': '2.0','type': 'video','cat': 'vp.mp4'})}
            r_vp = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/vp/upload.nhn', data=data, files=files)
            if r_vp.status_code != 201:
                raise Exception('Update profile video picture failure.')
            path_p = self.genTempFile('path')
            ff = FFmpeg(inputs={'%s' % path: None}, outputs={'%s' % path_p: ['-ss', '00:00:2', '-vframes', '1']})
            ff.run()
            self.updateProfilePicture(path_p, 'vp')
        except:
            raise Exception('You should install FFmpeg and ffmpy from pypi')

    # These function are still development. It doesn't works.
    # If you have a working code please pull it on linepy GitHub Repo 
开发者ID:soppeng29,项目名称:simpleSB,代码行数:19,代码来源:object.py

示例3: test_non_zero_exitcode_no_stdout

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_non_zero_exitcode_no_stdout():
    global_options = '--stdin none --stdout none --stderr multiline --exit-code 42'
    ff = FFmpeg(global_options=global_options)
    with pytest.raises(FFRuntimeError) as exc_info:
        ff.run(stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    assert exc_info.value.cmd == (
        "ffmpeg --stdin none --stdout none --stderr multiline --exit-code 42"
    )
    assert exc_info.value.exit_code == 42
    assert exc_info.value.stdout == b''
    assert exc_info.value.stderr == b'These are\nmultiple lines\nprinted to stderr'
    assert str(exc_info.value) == (
        "`ffmpeg --stdin none --stdout none --stderr multiline --exit-code 42` "
        'exited with status 42\n\n'
        'STDOUT:\n'
        '\n\n'
        'STDERR:\n'
        'These are\n'
        'multiple lines\n'
        'printed to stderr'
    ) 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:24,代码来源:test_cmd_execution.py

示例4: test_non_zero_exitcode_no_stdout_and_stderr

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_non_zero_exitcode_no_stdout_and_stderr():
    global_options = '--stdin none --stdout none --stderr none --exit-code 42'
    ff = FFmpeg(global_options=global_options)
    with pytest.raises(FFRuntimeError) as exc_info:
        ff.run(stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    assert exc_info.value.cmd == (
        "ffmpeg --stdin none --stdout none --stderr none --exit-code 42"
    )
    assert exc_info.value.exit_code == 42
    assert exc_info.value.stdout == b''
    assert exc_info.value.stderr == b''
    assert str(exc_info.value) == (
        "`ffmpeg --stdin none --stdout none --stderr none --exit-code 42` "
        'exited with status 42\n\n'
        'STDOUT:\n'
        '\n\n'
        'STDERR:\n'
    ) 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:21,代码来源:test_cmd_execution.py

示例5: test_terminate_process

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_terminate_process():
    global_options = '--long-run'
    ff = FFmpeg(global_options=global_options)

    thread_1 = threading.Thread(target=ff.run)
    thread_1.start()

    while not ff.process:
        time.sleep(0.05)

    print(ff.process.returncode)

    ff.process.terminate()
    thread_1.join()

    assert ff.process.returncode == -15 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:18,代码来源:test_cmd_execution.py

示例6: download

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def download(self, download_url, time):
        output_name = self.cid + '_' + str(time) + '.mp4'
        output = os.path.join(self.output_dir, output_name)

        ffmpeg_cmd = ffmpy.FFmpeg(
            r'C:\Program Files (x86)\ffmpeg-4.0.2\bin\ffmpeg.exe',
            '-t 0:01:15',
            inputs={download_url: None},
            outputs={output: None}
        )

        print('Start downloading and merging with ffmpeg...')
        print(ffmpeg_cmd.cmd)

        ffmpeg_cmd.run()


# bili = BilibiliLiveRecorder('3683436')
# time = 1
# while True:
#     bili.download(download_url=bili.get_live_url(), time=time)
#     print('Current Time: ' + str(time))
#     time += 1 
开发者ID:zachMelody,项目名称:bilibili-live-recorder,代码行数:25,代码来源:live_recorder.py

示例7: __run_ffmpeg

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def __run_ffmpeg(exe=im_ffm.get_ffmpeg_exe(), inputs=None, outputs=None):
        """ Run ffmpeg """
        logger.debug("Running ffmpeg: (exe: '%s', inputs: %s, outputs: %s", exe, inputs, outputs)
        ffm = FFmpeg(executable=exe, inputs=inputs, outputs=outputs)
        try:
            ffm.run(stderr=subprocess.STDOUT)
        except FFRuntimeError as ffe:
            # After receiving SIGINT ffmpeg has a 255 exit code
            if ffe.exit_code == 255:
                pass
            else:
                raise ValueError("An unexpected FFRuntimeError occurred: "
                                 "{}".format(ffe))
        except KeyboardInterrupt:
            pass  # Do nothing if voluntary interruption
        logger.debug("ffmpeg finished") 
开发者ID:deepfakes,项目名称:faceswap,代码行数:18,代码来源:effmpeg.py

示例8: updateProfileVideoPicture

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def updateProfileVideoPicture(self, path):
        try:
            from ffmpy import FFmpeg
            files = {'file': open(path, 'rb')}
            data = {'params': self.genOBSParams({'oid': self.profile.mid,'ver': '2.0','type': 'video','cat': 'vp.mp4'})}
            r_vp = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/vp/upload.nhn', data=data, files=files)
            if r_vp.status_code != 201:
                raise Exception('Update profile video picture failure.')
            path_p = self.genTempFile('path')
            ff = FFmpeg(inputs={'%s' % path: None}, outputs={'%s' % path_p: ['-ss', '00:00:2', '-vframes', '1']})
            ff.run()
            self.updateProfilePicture(path_p, 'vp')
        except:
            raise Exception('You should install FFmpeg and ffmpy from pypi') 
开发者ID:arifistifik,项目名称:dpk,代码行数:16,代码来源:object.py

示例9: convert_mp4_to_gif

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def convert_mp4_to_gif(mp4_file: [str, BytesIO], gif_file: str):
    """
    Reference: http://imageio.readthedocs.io/en/latest/examples.html#convert-a-movie
    :param mp4_file: full path or BytesIO object
    :param gif_file: full output path
    """
    if isinstance(mp4_file, str):
        input_file = mp4_file
    else:
        input_file = '/tmp/' + str(uuid4()) + '.mp4'
        f = open(input_file, 'wb')
        f.write(mp4_file.read())
        f.close()

    tmp_palettegen_path = '/tmp/' + str(uuid4()) + '.png'

    ff = ffmpy.FFmpeg(inputs={input_file: None},
                      outputs={tmp_palettegen_path: '-vf palettegen'},
                      global_options=('-y'))
    ff.run()
    ff = ffmpy.FFmpeg(inputs={input_file: None, tmp_palettegen_path: None},
                      outputs={gif_file: '-filter_complex paletteuse'},
                      global_options=('-y'))
    ff.run()
    os.remove(input_file)
    os.remove(tmp_palettegen_path) 
开发者ID:JQ-Networks,项目名称:UnifiedMessageRelay,代码行数:28,代码来源:UMRFile.py

示例10: test_invalid_executable_path

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_invalid_executable_path():
    ff = FFmpeg(executable='/tmp/foo/bar/ffmpeg')
    with pytest.raises(FFExecutableNotFoundError) as exc_info:
        ff.run()
    assert str(exc_info.value) == "Executable '/tmp/foo/bar/ffmpeg' not found" 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:7,代码来源:test_cmd_execution.py

示例11: test_no_redirection

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_no_redirection():
    global_options = '--stdin none --stdout oneline --stderr multiline --exit-code 0'
    ff = FFmpeg(global_options=global_options)
    stdout, stderr = ff.run()
    assert stdout is None
    assert stderr is None 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:8,代码来源:test_cmd_execution.py

示例12: test_redirect_to_devnull

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_redirect_to_devnull():
    global_options = '--stdin none --stdout oneline --stderr multiline --exit-code 0'
    ff = FFmpeg(global_options=global_options)
    devnull = open(os.devnull, 'wb')
    stdout, stderr = ff.run(stdout=devnull, stderr=devnull)
    assert stdout is None
    assert stderr is None 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:9,代码来源:test_cmd_execution.py

示例13: test_redirect_to_pipe

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_redirect_to_pipe():
    global_options = '--stdin none --stdout oneline --stderr multiline --exit-code 0'
    ff = FFmpeg(global_options=global_options)
    stdout, stderr = ff.run(stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    assert stdout == b'This is printed to stdout'
    assert stderr == b'These are\nmultiple lines\nprinted to stderr' 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:8,代码来源:test_cmd_execution.py

示例14: test_input

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_input():
    global_options = '--stdin pipe --stdout oneline --stderr multiline --exit-code 0'
    ff = FFmpeg(global_options=global_options)
    stdout, stderr = ff.run(
        input_data=b'my input data',
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    assert stdout == b'my input data\nThis is printed to stdout'
    assert stderr == b'These are\nmultiple lines\nprinted to stderr' 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:12,代码来源:test_cmd_execution.py

示例15: test_raise_exception_with_stdout_stderr_none

# 需要导入模块: import ffmpy [as 别名]
# 或者: from ffmpy import FFmpeg [as 别名]
def test_raise_exception_with_stdout_stderr_none():
    global_options = '--stdin none --stdout none --stderr none --exit-code 42'
    ff = FFmpeg(global_options=global_options)
    with pytest.raises(FFRuntimeError) as exc_info:
        ff.run()

    assert str(exc_info.value) == (
        "`ffmpeg --stdin none --stdout none --stderr none --exit-code 42` "
        'exited with status 42\n\n'
        'STDOUT:\n'
        '\n\n'
        'STDERR:\n'
    ) 
开发者ID:Ch00k,项目名称:ffmpy,代码行数:15,代码来源:test_cmd_execution.py


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