Skip to content

Commit 11db2b2

Browse files
author
Daniel Flores
committed
set reusable params for parametrized round trip test
1 parent 3586ee9 commit 11db2b2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/test_ops.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,19 +1406,20 @@ def test_video_encoder_round_trip(self, tmp_path, format, method):
14061406
asset = TEST_SRC_2_720P
14071407
source_frames = self.decode(file_path=str(asset.path)).data
14081408

1409-
frame_rate = 30 # Frame rate is fixed with num frames decoded
1409+
params = dict(
1410+
frame_rate=30, crf=0
1411+
) # Frame rate is fixed with num frames decoded
14101412
if method == "to_file":
14111413
encoded_path = str(tmp_path / f"encoder_output.{format}")
14121414
encode_video_to_file(
14131415
frames=source_frames,
1414-
frame_rate=frame_rate,
14151416
filename=encoded_path,
1416-
crf=0,
1417+
**params,
14171418
)
14181419
round_trip_frames = self.decode(file_path=encoded_path).data
14191420
else: # to_tensor
14201421
encoded_tensor = encode_video_to_tensor(
1421-
source_frames, frame_rate, format, crf=0
1422+
source_frames, format=format, **params
14221423
)
14231424
round_trip_frames = self.decode(tensor=encoded_tensor).data
14241425

@@ -1454,16 +1455,15 @@ def test_video_encoder_against_ffmpeg_cli(self, tmp_path, format):
14541455
)
14551456
asset = TEST_SRC_2_720P
14561457
source_frames = self.decode(str(asset.path)).data
1457-
frame_rate = 30
14581458

14591459
# Encode with FFmpeg CLI
14601460
temp_raw_path = str(tmp_path / "temp_input.raw")
14611461
with open(temp_raw_path, "wb") as f:
14621462
f.write(source_frames.permute(0, 2, 3, 1).cpu().numpy().tobytes())
14631463

14641464
ffmpeg_encoded_path = str(tmp_path / f"ffmpeg_output.{format}")
1465+
frame_rate = 30
14651466
crf = 0
1466-
quality_params = ["-crf", str(crf)]
14671467
# Some codecs (ex. MPEG4) do not support CRF.
14681468
# Flags not supported by the selected codec will be ignored.
14691469
ffmpeg_cmd = [
@@ -1479,7 +1479,8 @@ def test_video_encoder_against_ffmpeg_cli(self, tmp_path, format):
14791479
str(frame_rate),
14801480
"-i",
14811481
temp_raw_path,
1482-
*quality_params,
1482+
"-crf",
1483+
str(crf),
14831484
ffmpeg_encoded_path,
14841485
]
14851486
subprocess.run(ffmpeg_cmd, check=True)

0 commit comments

Comments
 (0)