def test_video_text_image(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_video_text_image")
        img = os.path.join(temp, '..', 'data', 'GastonLagaffe_1121.jpg')
        vidimg0 = video_image(img, duration=5, opacity=200)
        vidimg = video_position(vidimg0, lambda t: (0, 0), relative=True)

        text0 = video_text('boule',
                           size=2.,
                           color=(255, 0, 0, 128),
                           background=(0, 255, 0, 100))
        text = video_position(text0,
                              lambda t: (t * 0.1, t * 0.2),
                              relative=True)

        comb = video_compose([vidimg, text], t1=[0, 1])
        exp1 = os.path.join(temp, "courte_text.mp4")
        exp2 = os.path.join(temp, "courte_laga.mp4")
        video_save(text,
                   exp1,
                   fps=20,
                   duration=5,
                   verbose=__name__ == "__main__")
        video_save(comb,
                   exp2,
                   fps=20,
                   duration=5,
                   verbose=__name__ == "__main__")
        self.assertExists(exp1)
        self.assertExists(exp2)
        clean_video([text, text0, comb, vidimg, vidimg0])
Exemple #2
0
 def test_extract_frames_check_open(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     vid = video_load(
         os.path.join(os.path.dirname(__file__), 'data', 'videxa.mp4'))
     fra = list(video_enumerate_frames(vid, clean=True))
     self.assertEqual(len(fra), 78)
     self.assertEqual(fra[0].shape, (720, 404, 3))
     clean_video(vid)
Exemple #3
0
 def test_video_frame_sequence(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     temp = get_temp_folder(__file__, "temp_video_frame_images")
     fold = os.path.join(temp, "..", "data", "images")
     vid = video_frame(fold, fps=4)
     exp = os.path.join(temp, "courte.gif")
     video_save(vid, exp)
     self.assertExists(exp)
     clean_video(vid)
 def test_modify_avideo(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     temp = get_temp_folder(__file__, "temp_video_modification")
     vid = video_load(os.path.join(temp, '..', 'data', 'videxa.mp4'))
     vid2 = video_modification(vid, speed=2., mirrory=True, mirrorx=True)
     exp = os.path.join(temp, "courte2x.mp4")
     video_save(vid2, exp)
     self.assertExists(exp)
     clean_video([vid2, vid])
 def test_modify_avideo_blur(self):
     temp = get_temp_folder(__file__, "temp_videodl_face_blur")
     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",
         logger='bar' if __name__ == "__main__" else None)
     exp = os.path.join(temp, "face.mp4")
     video_save(vid2, exp)
     self.assertExists(exp)
     clean_video([vid2, vid, vide])
    def test_video_image_position(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_video_position")
        nimg = os.path.join(temp, '..', 'data', 'GastonLagaffe_1121.jpg')
        img = video_image(nimg, duration=60, zoom=(200, 200))
        exp = os.path.join(temp, "courte.mp4")
        video_save(img, exp, fps=20)
        self.assertExists(exp)
        clean_video(img)

        exp = os.path.join(temp, "courte05.mp4")
        img = video_image(nimg, duration=60, zoom=(200, 200))
        vid = video_position(img, (0.5, 0.5), relative=True)
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video([vid, img])

        exp = os.path.join(temp, "courtecb.mp4")
        img = video_image(nimg, duration=60, zoom=(200, 200))
        vid = video_position(img, ('center', 'bottom'), relative=True)
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video([vid, img])

        exp = os.path.join(temp, "courtefct.mp4")
        img = video_image(nimg, duration=60, zoom=(200, 200))
        vid = video_position(img, lambda t: (t * 0.1, t * 0.2), relative=True)
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video([vid, img])
 def test_extract_avideo(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     temp = get_temp_folder(__file__, "temp_video_extract")
     vid = os.path.join(temp, '..', 'data', 'videxa.mp4')
     vid2 = video_extract_video(vid, '00:00:01', '00:00:04')
     exp = os.path.join(temp, "courte.mp4")
     video_save(vid2, exp)
     self.assertExists(exp)
     exp = os.path.join(temp, "courte.gif")
     video_save(vid2, exp)
     self.assertExists(exp)
     clean_video(vid2)
    def test_compose_avideo(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_video_compose")
        vid = os.path.join(temp, '..', 'data', 'videxa.mp4')
        vid2 = video_compose(vid, vid, '00:00:01', '00:00:04')
        exp = os.path.join(temp, "courte.mp4")
        video_save(vid2, exp)
        self.assertExists(exp)

        exp = os.path.join(temp, "courte2.mp4")
        vid3 = video_concatenate([vid, vid])
        video_save(vid3, exp)
        self.assertExists(exp)
        clean_video(vid3)
 def test_video_audio_bug(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     temp = get_temp_folder(__file__, "temp_video_audio_bug")
     vid = os.path.join(temp, '..', 'data', 'videxa.mp4')
     audio = video_extract_audio(vid)
     vid2 = video_modification(vid, speed=2., mirrory=True, mirrorx=True)
     audio1 = video_extract_audio(vid2)
     audio3 = audio_concatenate([audio1, audio, audio1, audio1])
     vid3 = video_concatenate([vid, vid2])
     vid4 = video_replace_audio(vid3, audio3)
     exp = os.path.join(temp, "courte2x.mp4")
     video_save(vid4, exp)
     self.assertExists(exp)
     clean_video([vid4, vid2, vid3, audio, audio1, audio3])
 def test_modify_avideo(self):
     temp = get_temp_folder(__file__, "temp_videodl_face_rect")
     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",
         logger='bar' if __name__ == "__main__" else None)
     exp = os.path.join(temp, "face.mp4")
     self.assertTrue(vid2.make_frame is not None)
     video_save_image(vid2, t=1, filename=os.path.join(temp, "img1.jpg"))
     im = video_save_image(vid2, t=2)
     im.save(os.path.join(temp, "img2.png"))
     video_save(vid2, exp, verbose=__name__ == "__main__")
     self.assertExists(exp)
     clean_video([vid2, vid, vide])
Exemple #11
0
    def test_video_frame(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        import gizeh
        temp = get_temp_folder(__file__, "temp_video_frame")

        def make_frame(t):
            # See example: https://zulko.github.io/moviepy/getting_started/videoclips.html#videoclip
            surface = gizeh.Surface(128, 128)
            radius = 100 * (1 + (t * (2 - t))**2) / 6
            circle = gizeh.circle(radius, xy=(64, 64), fill=(1, 0, 0))
            circle.draw(surface)
            return surface.get_npimage()

        vid = video_frame(make_frame)
        exp = os.path.join(temp, "courte.gif")
        video_save(vid, exp, fps=20, duration=2)
        self.assertExists(exp)
        clean_video(vid)
Exemple #12
0
    def test_video_text(self):
        temp = get_temp_folder(__file__, "temp_video_text")
        vid = img = video_text('boule')
        exp = os.path.join(temp, "courte.mp4")
        video_save(vid,
                   exp,
                   fps=20,
                   duration=3,
                   verbose=__name__ == "__main__")
        self.assertExists(exp)
        clean_video(vid)

        exp = os.path.join(temp, "courtefct.mp4")
        vid = video_position(img, lambda t: (t * 0.1, t * 0.2), relative=True)
        video_save(vid,
                   exp,
                   fps=20,
                   duration=4,
                   verbose=__name__ == "__main__")
        self.assertExists(exp)
        clean_video(vid)
    def test_modify_placement(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_video_placement")
        vid = video_load(os.path.join(temp, '..', 'data', 'videxa.mp4'))

        vid2 = video_compose(vid, vid, t2=1, place='h2')
        exp = os.path.join(temp, "h2.mp4")
        video_save(vid2, exp)
        self.assertExists(exp)
        clean_video([vid2, vid])

        vid = video_load(os.path.join(temp, '..', 'data', 'videxa.mp4'))
        vid2 = video_compose(vid, vid, t2=1, place='v2')
        exp = os.path.join(temp, "v2.mp4")
        video_save(vid2, exp)
        self.assertExists(exp)
        clean_video([vid2, vid])

        vid = video_load(os.path.join(temp, '..', 'data', 'videxa.mp4'))
        vid2 = video_compose(vid, vid, t2=1, place='br', zoom=0.2)
        exp = os.path.join(temp, "br.mp4")
        video_save(vid2, exp)
        self.assertExists(exp)
        clean_video([vid2, vid])
    def test_video_image_resize(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_video_resize")
        nimg = os.path.join(temp, '..', 'data', 'GastonLagaffe_1121.jpg')
        vid = video_image(nimg, duration=60, zoom=(200, 200))
        exp = os.path.join(temp, "courte.mp4")
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video(vid)

        exp = os.path.join(temp, "courtecb.mp4")
        img = video_image(nimg, duration=60, zoom=(200, 200))
        vid = video_resize(img, 0.5)
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video([vid, img])

        exp = os.path.join(temp, "courtefct.mp4")
        img = video_image(nimg, duration=60, zoom=(200, 200))
        vid = video_resize(img, lambda t: max(0.1, 1 - 0.1 * t))
        video_save(vid, exp, fps=20)
        self.assertExists(exp)
        clean_video([vid, img])