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