Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemia committed Jan 5, 2025
1 parent 7b3f899 commit a22167c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/ffmpeg/dag/tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
id="filter-node",
),
pytest.param(
input(filename="tmp.mp4").output(filename="temp").global_args(y=True, no=False, speed=1).node,
input(filename="tmp.mp4")
.output(filename="temp")
.global_args(y=True, extra_options={"no": False, "speed": 1})
.node,
GlobalNode,
id="global-node",
),
Expand Down
30 changes: 22 additions & 8 deletions src/ffmpeg/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,24 @@ def test_generate_thumbnail_for_video(snapshot: SnapshotAssertion) -> None:
def test_assemble_video_from_sequence_of_frames(snapshot: SnapshotAssertion) -> None:
# ["ffmpeg", "-framerate", "25", "-pattern_type", "glob", "-i", "/path/to/jpegs/*.jpg", "movie.mp4""]
assert snapshot(extension_class=JSONSnapshotExtension) == (
input("/path/to/jpegs/*.jpg", framerate=25, pattern_type="glob").output(filename="movie.mp4").compile()
input("/path/to/jpegs/*.jpg", extra_options={"framerate": 25, "pattern_type": "glob"})
.output(filename="movie.mp4")
.compile()
)


def test_assemble_video_from_sequence_of_frames_with_additional_filtering(snapshot: SnapshotAssertion) -> None:
# ["ffmpeg", "-framerate", "25", "-pattern_type", "glob", "-i", "/path/to/jpegs/*.jpg", "-filter_complex", "[0]deflicker=mode=pm:size=10[s0];[s0]scale=force_original_aspect_ratio=increase:size=hd1080[s1]", "-map", "[s1]", "-crf", "20", "-movflags", "faststart", "-pix_fmt", "yuv420p", "-preset", "slower", "movie.mp4"]
assert snapshot(extension_class=JSONSnapshotExtension) == (
input("/path/to/jpegs/*.jpg", framerate=25, pattern_type="glob")
input("/path/to/jpegs/*.jpg", extra_options={"framerate": 25, "pattern_type": "glob"})
.deflicker(mode="pm", size=10)
# FIXME: scale's w,h options should be optional
.scale(size="hd1080", force_original_aspect_ratio="increase")
.output(filename="movie.mp4", crf=20, movflags="faststart", pix_fmt="yuv420p", preset="slower")
.scale(force_original_aspect_ratio="increase", extra_options={"size": "hd1000"})
.output(
filename="movie.mp4",
pix_fmt="yuv420p",
extra_options={"crf": 20, "movflags": "faststart", "preset": "slower"},
)
.compile()
)

Expand Down Expand Up @@ -124,11 +130,17 @@ def test_drawtext_escaping(snapshot: SnapshotAssertion) -> None:

def test_compile_bool_option(snapshot: SnapshotAssertion) -> None:
assert snapshot(extension_class=JSONSnapshotExtension) == (
input("input.mp4").drawtext(text="hello", escape_text=False).output(filename="output.mp4").compile()
input("input.mp4")
.drawtext(text="hello", extra_options={"escape_text": False})
.output(filename="output.mp4")
.compile()
)

assert snapshot(extension_class=JSONSnapshotExtension) == (
input("input.mp4").drawtext(text="hello", escape_text=True).output(filename="output.mp4").compile()
input("input.mp4")
.drawtext(text="hello", extra_options={"escape_text": True})
.output(filename="output.mp4")
.compile()
)


Expand Down Expand Up @@ -157,8 +169,10 @@ def test_concat_dumuxer(snapshot: SnapshotAssertion) -> None:
stream = input(
"files.txt",
f="concat",
safe="0",
protocol_whitelist="file,http,https,tcp,tls",
extra_options={
"safe": 0,
"protocol_whitelist": "file,http,https,tcp,tls",
},
)

assert snapshot(extension_class=JSONSnapshotExtension) == (stream.output(filename="output.mp4").compile())
Expand Down

0 comments on commit a22167c

Please sign in to comment.