Skip to content

Commit e31c631

Browse files
committed
Update to pydantic config dict, and fix tests for linux
1 parent a7b6478 commit e31c631

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

fastflix/models/encode.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
from typing import Optional, Union
44

5-
from pydantic import BaseModel, Field, field_validator
5+
from pydantic import BaseModel, Field, field_validator, ConfigDict
66
from box import Box
77

88

@@ -24,8 +24,7 @@ class AudioTrack(BaseModel):
2424
raw_info: Optional[Union[dict, Box]] = None
2525
dispositions: dict = Field(default_factory=dict)
2626

27-
class Config:
28-
arbitrary_types_allowed = True
27+
model_config = ConfigDict(arbitrary_types_allowed=True)
2928

3029

3130
class SubtitleTrack(BaseModel):
@@ -40,8 +39,7 @@ class SubtitleTrack(BaseModel):
4039
long_name: str = ""
4140
raw_info: Optional[Union[dict, Box]] = None
4241

43-
class Config:
44-
arbitrary_types_allowed = True
42+
model_config = ConfigDict(arbitrary_types_allowed=True)
4543

4644

4745
class AttachmentTrack(BaseModel):

fastflix/models/video.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import List, Optional, Union, Tuple
55

66
from box import Box
7-
from pydantic import BaseModel, Field, field_validator
7+
from pydantic import BaseModel, Field, field_validator, ConfigDict
88

99
from fastflix.models.encode import (
1010
AOMAV1Settings,
@@ -309,5 +309,4 @@ def scale(self):
309309
else:
310310
return f"-8:{self.video_settings.resolution_custom}"
311311

312-
class Config:
313-
arbitrary_types_allowed = True
312+
model_config = ConfigDict(arbitrary_types_allowed=True)

tests/encoders/test_avc_x264_command_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def test_avc_x264_two_pass_bitrate():
8282

8383
# The expected command should be a list of two Command objects for two-pass encoding
8484
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 NUL',
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',
8686
'ffmpeg -y -i input.mkv --color_details -pass 2 -passlogfile "work_path\\pass_log_file_abcdef1234" -b:v 5000k -preset:v medium output.mkv',
8787
]
8888
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
8989
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
90-
assert result[0].command == expected_commands[0], (
90+
assert result[0].command.startswith(expected_commands[0]), (
9191
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
9292
)
9393
assert result[1].command == expected_commands[1], (

tests/encoders/test_ffmpeg_hevc_nvenc_command_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ def test_ffmpeg_hevc_nvenc_bitrate():
9595

9696
# The expected command should be a list of two Command objects for two-pass encoding
9797
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 NUL',
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',
9999
'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',
100100
]
101101
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
102102
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
103-
assert result[0].command == expected_commands[0], (
103+
assert result[0].command.startswith(expected_commands[0]), (
104104
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
105105
)
106106
assert result[1].command == expected_commands[1], (

tests/encoders/test_hevc_x265_command_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def test_hevc_x265_two_pass_bitrate():
8383

8484
# The expected command should be a list of two Command objects for two-pass encoding
8585
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 NUL',
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',
8787
'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',
8888
]
8989
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
9090
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
91-
assert result[0].command == expected_commands[0], (
91+
assert result[0].command.startswith(expected_commands[0]), (
9292
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
9393
)
9494
assert result[1].command == expected_commands[1], (

tests/encoders/test_svt_av1_command_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def test_svt_av1_two_pass_qp():
8585

8686
# The expected command should be a list of two Command objects for two-pass encoding
8787
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 NUL',
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',
8989
'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',
9090
]
9191
assert isinstance(result, list), f"Expected a list of Command objects, got {type(result)}"
9292
assert len(result) == 2, f"Expected 2 Command objects, got {len(result)}"
93-
assert result[0].command == expected_commands[0], (
93+
assert result[0].command.startswith(expected_commands[0]), (
9494
f"Expected: {expected_commands[0]}\nGot: {result[0].command}"
9595
)
9696
assert result[1].command == expected_commands[1], (

0 commit comments

Comments
 (0)