當前位置: 首頁>>代碼示例>>Python>>正文


Python moviepy.editor方法代碼示例

本文整理匯總了Python中moviepy.editor方法的典型用法代碼示例。如果您正苦於以下問題:Python moviepy.editor方法的具體用法?Python moviepy.editor怎麽用?Python moviepy.editor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moviepy的用法示例。


在下文中一共展示了moviepy.editor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: npy_to_video

# 需要導入模塊: import moviepy [as 別名]
# 或者: from moviepy import editor [as 別名]
def npy_to_video(npy, filename, fps=10, preview=True, convert='gif'):
    """Convert a numpy array into a gif file at the location specified by filename.

        # Arguments

        convert: Default empty string is no conversion, options are gif and mp4.
        preview: pop open a preview window to view the video data.
    """
    # Useful moviepy instructions https://github.com/Zulko/moviepy/issues/159
    # TODO(ahundt) currently importing moviepy prevents python from exiting. Once this is resolved remove the import below.
    import moviepy.editor as mpy
    clip = mpy.ImageSequenceClip(list(npy), fps)
    if preview:
        # https://stackoverflow.com/a/41771413
        clip.preview()
    if convert == 'gif':
        clip.write_gif(filename)
    elif convert:
        clip.write_videofile(filename) 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:21,代碼來源:view_convert_dataset.py

示例2: test_raises_error_if_moviepy_not_available

# 需要導入模塊: import moviepy [as 別名]
# 或者: from moviepy import editor [as 別名]
def test_raises_error_if_moviepy_not_available(self):
        # OK, so this is a nasty nasty test with import fuckery going on.
        try:
            # First we make moviepy.editor unimportable
            sys.modules["moviepy.editor"] = None
            # but we have already imported torchvideo.tools so that code is
            # cached with a reference to the *original* moviepy, so we need to reload
            # it to invoke the failure path of the import code
            importlib.reload(torchvideo.tools)
            from torchvideo.tools import show_video

            # Now we've imported torchvideo.tools where moviepy.editor was
            # *not* available.
            with pytest.raises(ImportError, match="please install moviepy"):
                show_video(self.frames)
        finally:
            # We've borked up the system modules and we have to put them right otherwise
            # any tests that depend on torchvideo.tools or moviepy.editor are
            # going to fail.
            # We first restore the original moviepy editor object back
            sys.modules["moviepy.editor"] = original_moviepy_editor
            # I don't think we need to reload moviepy (other tests pass without this
            # line), but for good measure let's reload it just in case it does
            # something useful.
            importlib.reload(moviepy)
            # We also want to reload torchvideo.tools so moviepy *is* available
            importlib.reload(torchvideo.tools) 
開發者ID:torchvideo,項目名稱:torchvideo,代碼行數:29,代碼來源:test_show_video.py

示例3: test_uses_ipython_display_if_ipython_is_available

# 需要導入模塊: import moviepy [as 別名]
# 或者: from moviepy import editor [as 別名]
def test_uses_ipython_display_if_ipython_is_available(self, monkeypatch):
        display_mock = Mock()
        with monkeypatch.context() as ctx:
            ctx.setattr(moviepy.video.io.html_tools, "ipython_available", True)
            ctx.setattr(
                moviepy.editor.ImageSequenceClip, "ipython_display", display_mock
            )

            importlib.reload(torchvideo.tools)
            show_video(self.frames)

            display_mock.assert_called_once_with() 
開發者ID:torchvideo,項目名稱:torchvideo,代碼行數:14,代碼來源:test_show_video.py

示例4: test_fallsback_on_pygame_display

# 需要導入模塊: import moviepy [as 別名]
# 或者: from moviepy import editor [as 別名]
def test_fallsback_on_pygame_display(self, monkeypatch):
        show_mock = Mock()
        with monkeypatch.context() as ctx:
            ctx.setattr(moviepy.video.io.html_tools, "ipython_available", False)
            ctx.setattr(moviepy.editor.ImageSequenceClip, "show", show_mock)

            importlib.reload(torchvideo.tools)
            show_video(self.frames)

            show_mock.assert_called_once_with() 
開發者ID:torchvideo,項目名稱:torchvideo,代碼行數:12,代碼來源:test_show_video.py


注:本文中的moviepy.editor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。