Skip to content

Commit 4450263

Browse files
committed
Fix tests for linux
1 parent c470580 commit 4450263

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

pyproject.toml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ dependencies = [
2727
"ffmpeg-normalize>=1.31.3,<2.0",
2828
]
2929

30-
[project.optional-dependencies]
31-
develop = [
32-
"wheel>=0.38.4",
33-
"typing_extensions>=4.4",
34-
"pyinstaller==6.13.0",
35-
"pytest>=7.3",
36-
"types-requests>=2.28",
37-
"types-setuptools>=65.7",
38-
"pre-commit>=3.0",
39-
"ruff>=0.12"
40-
]
41-
4230
[project.scripts]
4331
fastflix = "fastflix.__main__:start_fastflix"
4432

tests/encoders/test_avc_x264_command_builder.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from unittest import mock
33

4+
import reusables
5+
46
from fastflix.encoders.avc_x264.command_builder import build
57
from fastflix.models.encode import x264Settings
68
from fastflix.models.video import VideoSettings
@@ -81,13 +83,19 @@ def test_avc_x264_two_pass_bitrate():
8183
result = build(fastflix)
8284

8385
# The expected command should be a list of two Command objects for two-pass encoding
84-
expected_commands = [
85-
'ffmpeg -y -i input.mkv --color_details -pass 1 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 5000k -preset:v medium -an -sn -dn -r 24 -f mp4',
86-
'ffmpeg -y -i input.mkv --color_details -pass 2 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 5000k -preset:v medium output.mkv',
87-
]
86+
if reusables.win_based:
87+
expected_commands = [
88+
'ffmpeg -y -i input.mkv --color_details -pass 1 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 5000k -preset:v medium -an -sn -dn -r 24 -f mp4 NUL',
89+
'ffmpeg -y -i input.mkv --color_details -pass 2 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 5000k -preset:v medium output.mkv',
90+
]
91+
else:
92+
expected_commands = [
93+
'ffmpeg -y -i input.mkv --color_details -pass 1 -passlogfile "work_path/pass_log_file_abcdef1234" -b:v 5000k -preset:v medium -an -sn -dn -r 24 -f mp4 /dev/null',
94+
'ffmpeg -y -i input.mkv --color_details -pass 2 -passlogfile "work_path/pass_log_file_abcdef1234" -b:v 5000k -preset:v medium output.mkv',
95+
]
8896
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
8997
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
90-
assert result[0].command.startswith(expected_commands[0]), (
98+
assert result[0].command == expected_commands[0], (
9199
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
92100
)
93101
assert result[1].command == expected_commands[1], (

tests/encoders/test_ffmpeg_hevc_nvenc_command_builder.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from unittest import mock
33

4+
import reusables
5+
46
from fastflix.encoders.ffmpeg_hevc_nvenc.command_builder import build
57
from fastflix.models.encode import FFmpegNVENCSettings
68
from fastflix.models.video import VideoSettings
@@ -94,13 +96,19 @@ def test_ffmpeg_hevc_nvenc_bitrate():
9496
result = build(fastflix)
9597

9698
# The expected command should be a list of two Command objects for two-pass encoding
97-
expected_commands = [
98-
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 1 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 6000k -preset:v slow -2pass 1 -an -sn -dn -r 24 -f mp4',
99-
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 2 -passlogfile "work_path\\pass_log_file_abcdef1234" -2pass 1 -b:v 6000k -preset:v slow output.mkv',
100-
]
99+
if reusables.win_based:
100+
expected_commands = [
101+
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 1 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 6000k -preset:v slow -2pass 1 -an -sn -dn -r 24 -f mp4 NUL',
102+
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 2 -passlogfile "work_path\\pass_log_file_abcdef1234" -2pass 1 -b:v 6000k -preset:v slow output.mkv',
103+
]
104+
else:
105+
expected_commands = [
106+
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 1 -passlogfile "work_path/pass_log_file_abcdef1234" -b:v 6000k -preset:v slow -2pass 1 -an -sn -dn -r 24 -f mp4 /dev/null',
107+
'ffmpeg -y -i input.mkv -tune:v hq --color_details -spatial_aq:v 0 -tier:v main -rc-lookahead:v 0 -gpu -1 -b_ref_mode disabled -profile:v main -pass 2 -passlogfile "work_path/pass_log_file_abcdef1234" -2pass 1 -b:v 6000k -preset:v slow output.mkv',
108+
]
101109
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
102110
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
103-
assert result[0].command.startswith(expected_commands[0]), (
111+
assert result[0].command == expected_commands[0], (
104112
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
105113
)
106114
assert result[1].command == expected_commands[1], (

tests/encoders/test_hevc_x265_command_builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from unittest import mock
33

4+
import reusables
5+
46
from fastflix.encoders.hevc_x265.command_builder import build
57
from fastflix.models.encode import x265Settings
68
from fastflix.models.video import VideoSettings
@@ -83,12 +85,12 @@ def test_hevc_x265_two_pass_bitrate():
8385

8486
# The expected command should be a list of two Command objects for two-pass encoding
8587
expected_commands = [
86-
'ffmpeg -y -i input.mkv -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0:pass=1:no-slow-firstpass=1:stats=pass_log_file_abcdef1234.log" -b:v 5000k -preset:v medium -an -sn -dn None -f mp4',
88+
f'ffmpeg -y -i input.mkv -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0:pass=1:no-slow-firstpass=1:stats=pass_log_file_abcdef1234.log" -b:v 5000k -preset:v medium -an -sn -dn None -f mp4 {"NUL" if reusables.win_based else "/dev/null"}',
8789
'ffmpeg -y -i input.mkv -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0:pass=2:stats=pass_log_file_abcdef1234.log" -b:v 5000k -preset:v medium output.mkv',
8890
]
8991
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
9092
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
91-
assert result[0].command.startswith(expected_commands[0]), (
93+
assert result[0].command == expected_commands[0], (
9294
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
9395
)
9496
assert result[1].command == expected_commands[1], (

tests/encoders/test_svt_av1_command_builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from unittest import mock
33

4+
import reusables
5+
46
from fastflix.encoders.svt_av1.command_builder import build
57
from fastflix.models.encode import SVTAV1Settings
68
from fastflix.models.video import VideoSettings
@@ -85,12 +87,12 @@ def test_svt_av1_two_pass_qp():
8587

8688
# The expected command should be a list of two Command objects for two-pass encoding
8789
expected_commands = [
88-
'ffmpeg -y -i input.mkv -strict experimental -preset 7 --color_details -svtav1-params "tile-columns=0:tile-rows=0:scd=0:color-primaries=9:transfer-characteristics=16:matrix-coefficients=9" -passlogfile "pass_log_file_abcdef1234" -crf 24 -pass 1 -an -r 24 -f matroska',
90+
f'ffmpeg -y -i input.mkv -strict experimental -preset 7 --color_details -svtav1-params "tile-columns=0:tile-rows=0:scd=0:color-primaries=9:transfer-characteristics=16:matrix-coefficients=9" -passlogfile "pass_log_file_abcdef1234" -crf 24 -pass 1 -an -r 24 -f matroska {"NUL" if reusables.win_based else "/dev/null"}',
8991
'ffmpeg -y -i input.mkv -strict experimental -preset 7 --color_details -svtav1-params "tile-columns=0:tile-rows=0:scd=0:color-primaries=9:transfer-characteristics=16:matrix-coefficients=9" -passlogfile "pass_log_file_abcdef1234" -crf 24 -pass 2 output.mkv',
9092
]
9193
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
9294
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
93-
assert result[0].command.startswith(expected_commands[0]), (
95+
assert result[0].command == expected_commands[0], (
9496
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
9597
)
9698
assert result[1].command == expected_commands[1], (

0 commit comments

Comments
 (0)