test_movie_video.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from panda3d.core import MovieVideo
  2. from panda3d.core import Filename
  3. from panda3d.core import PandaSystem
  4. import pytest
  5. import os
  6. def check_ffmpeg():
  7. # Make sure video plug-ins are loaded
  8. MovieVideo.get("test.mp4")
  9. system = PandaSystem.get_global_ptr()
  10. return 'FFmpeg' in system.systems #checks whether ffmpeg is loaded
  11. @pytest.mark.skipif(not check_ffmpeg(), reason="skip when ffmpeg is not available")
  12. class Test_Video_Movie():
  13. def test_cursor_check(self):
  14. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  15. movie_path = Filename.from_os_specific(movie_path)
  16. reference_file = MovieVideo.get(movie_path)
  17. assert reference_file.get_filename() == movie_path
  18. assert reference_file.open() is not None
  19. def test_video_length(self):
  20. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  21. movie_path = Filename.from_os_specific(movie_path)
  22. reference_file = MovieVideo.get(movie_path)
  23. cursor = reference_file.open()
  24. assert cursor.length() == 32.4800
  25. def test_video_size(self):
  26. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  27. movie_path = Filename.from_os_specific(movie_path)
  28. reference_file = MovieVideo.get(movie_path)
  29. cursor = reference_file.open()
  30. assert cursor.size_x() == 640 #found the height and width using mkvinfo
  31. assert cursor.size_y() == 360