Skip to content

Commit

Permalink
fix #441 change filter_node_factory's parameter's name to avoid confl…
Browse files Browse the repository at this point in the history
…ict (#443)
  • Loading branch information
lucemia authored Feb 14, 2025
1 parent 2ff2d7d commit ea318f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ffmpeg/dag/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,42 @@


def filter_node_factory(
filter: FFMpegFilterDef, *inputs: FilterableStream, **kwargs: Any
ffmpeg_filter_def: FFMpegFilterDef, *inputs: FilterableStream, **kwargs: Any
) -> FilterNode:
for k, v in kwargs.items():
if isinstance(v, Auto):
kwargs[k] = eval(
v, {"StreamType": StreamType, "re": re, **kwargs, "streams": inputs}
)

if isinstance(filter.typings_input, str):
if isinstance(ffmpeg_filter_def.typings_input, str):
input_typings = tuple(
eval(filter.typings_input, {"StreamType": StreamType, "re": re, **kwargs})
eval(
ffmpeg_filter_def.typings_input,
{"StreamType": StreamType, "re": re, **kwargs},
)
)
else:
input_typings = tuple(
StreamType.video if k == "video" else StreamType.audio
for k in filter.typings_input
for k in ffmpeg_filter_def.typings_input
)

if isinstance(filter.typings_output, str):
if isinstance(ffmpeg_filter_def.typings_output, str):
output_typings = tuple(
eval(filter.typings_output, {"StreamType": StreamType, "re": re, **kwargs})
eval(
ffmpeg_filter_def.typings_output,
{"StreamType": StreamType, "re": re, **kwargs},
)
)
else:
output_typings = tuple(
StreamType.video if k == "video" else StreamType.audio
for k in filter.typings_output
for k in ffmpeg_filter_def.typings_output
)

return FilterNode(
name=filter.name,
name=ffmpeg_filter_def.name,
input_typings=input_typings,
output_typings=output_typings,
inputs=inputs,
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions src/ffmpeg/streams/tests/__snapshots__/test_audio.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# serializer version: 1
# name: test_showwavespic
"ffmpeg -i test-input.mp4 -filter_complex '[0:a]showwavespic[s0]' -map '[s0]' -f image2 -vframes 1 -vcodec mjpeg pipe:"
# ---
12 changes: 12 additions & 0 deletions src/ffmpeg/streams/tests/test_audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from syrupy.assertion import SnapshotAssertion

import ffmpeg


def test_showwavespic(snapshot: SnapshotAssertion) -> None:
assert snapshot == (
ffmpeg.input("test-input.mp4")
.audio.showwavespic()
.output(filename="pipe:", vframes=1, f="image2", vcodec="mjpeg")
.compile_line()
)

0 comments on commit ea318f3

Please sign in to comment.