Skip to content

Commit

Permalink
add unit test for conert_video
Browse files Browse the repository at this point in the history
  • Loading branch information
jwong-nd committed Nov 6, 2024
1 parent 36e1c61 commit b70512f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/aind_behavior_video_transformation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
from aind_behavior_video_transformation.transform_videos import ( # noqa F401
CompressionEnum,
CompressionRequest,
convert_video
)
23 changes: 23 additions & 0 deletions tests/test_transform_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BehaviorVideoJobSettings,
CompressionEnum,
CompressionRequest,
convert_video
)


Expand Down Expand Up @@ -52,6 +53,28 @@ class TestBehaviorVideoJob(unittest.TestCase):
test_vid_name = "clip.mp4"
test_vid_path = test_data_path / test_vid_name

@patch("aind_behavior_video_transformation.etl.time")
def test_convert_video(self, mock_time: MagicMock):
"""Unit test convert video."""

# Equivalent to CompressionEnum.GAMMA_ENCODING
arg_set = ("", "-vf "
'"scale=out_color_matrix=bt709:out_range=full:sws_dither=none,'
"format=yuv420p10le,colorspace=ispace=bt709:all=bt709:dither=none,"
'scale=out_range=tv:sws_dither=none,format=yuv420p" -c:v libx264 '
"-preset veryslow -crf 18 -pix_fmt yuv420p "
'-metadata author="Allen Institute for Neural Dyamics" '
"-movflags +faststart+write_colr")
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)
compressed_out_path = convert_video(self.test_vid_path,
temp_path,
arg_set)

out_path = temp_path / self.test_vid_name

self.assertTrue(str(out_path) == str(compressed_out_path))

@patch("aind_behavior_video_transformation.etl.time")
def test_run_job(self, mock_time: MagicMock):
"""Tests run_job method."""
Expand Down

0 comments on commit b70512f

Please sign in to comment.