Permalink
Browse files

tries to get rid of open processes

  • Loading branch information...
sdpython committed Jan 20, 2018
1 parent 065cbe9 commit 5ace0a93b926b5364c200594e543efa3b5d65ae4
@@ -47,7 +47,7 @@
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from src.code_beatrix.art.videodl import video_map_images
from src.code_beatrix.art.video import video_save, video_extract_video, video_save_image, clean_video
from src.code_beatrix.art.video import video_save, video_extract_video, video_save_image, clean_video, video_load
class TestVideoDLFace(ExtTestCase):
@@ -58,22 +58,23 @@ def test_modify_avideo_blur(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_videodl_face_blur")
vid = os.path.join(temp, '..', 'data', 'charlie.mp4')
vid = video_load(os.path.join(temp, '..', 'data', 'charlie.mp4'))
vide = video_extract_video(vid, 0, 5 if __name__ == "__main__" else 1)
vid2 = video_map_images(
vide, fps=10, name="detect", progress_bar=__name__ == "__main__", fLOG=fLOG)
exp = os.path.join(temp, "face.mp4")
video_save(vid2, exp)
self.assertExists(exp)
clean_video(vid2)
clean_video(vid)
def test_modify_avideo(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_videodl_face_rect")
vid = os.path.join(temp, '..', 'data', 'charlie.mp4')
vid = video_load(os.path.join(temp, '..', 'data', 'charlie.mp4'))
vide = video_extract_video(vid, 0, 10 if __name__ == "__main__" else 1)
vid2 = video_map_images(
vide, fps=10, name="detect", action="rect", progress_bar=__name__ == "__main__", fLOG=fLOG)
@@ -85,6 +86,7 @@ def test_modify_avideo(self):
video_save(vid2, exp, verbose=__name__ == "__main__")
self.assertExists(exp)
clean_video(vid2)
clean_video(vid)
if __name__ == "__main__":
@@ -148,6 +148,8 @@ def clean_video(video):
* `The handle is invalid - Windows Only <https://github.com/Zulko/moviepy/issues/697>`_
"""
if isinstance(video, str):
raise TypeError("Unexpected type (string)")
if hasattr(video, 'reader'):
video.reader.close()
if hasattr(video.audio, 'reader'):
@@ -297,6 +297,18 @@ def video_extract_video(video_or_file, ta=0, tb=None):
return video.subclip(ta, tb)
def video_load(video_or_file):
"""
Loads a video.
Charge une vidéo.
@param video_or_file string or :epkg:`VideoClip`
@return :epkg:`VideoClip`
"""
with VideoContext(video_or_file) as video:
return video.video
def video_save_image(video_or_file, t=None, filename=None, **kwargs):
"""
Saves one image from a video.

0 comments on commit 5ace0a9

Please sign in to comment.