当前位置: 首页>>代码示例>>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;未经允许,请勿转载。