Skip to content

Commit

Permalink
fix #425 enable -no for global options (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemia authored Jan 15, 2025
1 parent 1e6613d commit 997592b
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/ffmpeg/dag/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def get_args(self, context: DAGContext = None) -> list[str]:
if isinstance(value, bool):
if value is True:
commands += [f"-{key}"]
elif value is False:
commands += [f"-no{key}"]
# NOTE: the -no{key} format since not really for global options
else:
commands += [f"-{key}", str(value)]
Expand Down
12 changes: 11 additions & 1 deletion src/ffmpeg/dag/tests/__snapshots__/test_nodes.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@
"GlobalNode(kwargs=(('y', True), ('no', False), ('speed', 1)), inputs=(OutputStream(node=OutputNode(kwargs=(), inputs=(AVStream(node=InputNode(kwargs=(), inputs=(), filename='tmp.mp4'), index=None),), filename='temp'), index=None),))"
# ---
# name: test_node_prop[global-node][f.repr]
'-y -speed 1'
'-y -nono -speed 1'
# ---
# name: test_node_prop[global-node][get_args]
list([
'-y',
'-nono',
'-speed',
'1',
])
Expand Down Expand Up @@ -94,3 +95,12 @@
'test.mp4',
])
# ---
# name: test_nostdin
list([
'ffmpeg',
'-nostdin',
'-i',
'tmp1.mp4',
'output.mp4',
])
# ---
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"ffmpeg",
"-non",
"-y",
"-i",
"tmp1.mp4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"ffmpeg -i tmp1.mp4 -i tmp2.mp4 -filter_complex '[0:v][1:v]concat=n=2[s0]' -map '[s0]' output.mp4"
"ffmpeg -non -i tmp1.mp4 -i tmp2.mp4 -filter_complex '[0:v][1:v]concat=n=2[s0]' -map '[s0]' output.mp4"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"ffmpeg",
"-non",
"-i",
"tmp1.mp4",
"-i",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
[]
[
"-non"
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"ffmpeg",
"-noy",
"-n",
"-i",
"tmp1.mp4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"ffmpeg -i tmp1.mp4 -i tmp2.mp4 -filter_complex '[0:v][1:v]concat=n=2[s0]' -map '[s0]' output.mp4"
"ffmpeg -noy -i tmp1.mp4 -i tmp2.mp4 -filter_complex '[0:v][1:v]concat=n=2[s0]' -map '[s0]' output.mp4"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"ffmpeg",
"-noy",
"-i",
"tmp1.mp4",
"-i",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
[]
[
"-noy"
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/ffmpeg/dag/tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def test_global_node_with_args_overwrite(
assert snapshot(extension_class=DAGSnapshotExtenstion, name="graph") == stream.node


def test_nostdin(snapshot: SnapshotAssertion) -> None:
input1 = input("tmp1.mp4")
stream = input1.output(filename="output.mp4").global_args(stdin=False)
assert stream.compile() == snapshot


def test_filter_node_with_outputs(snapshot: SnapshotAssertion) -> None:
input1 = input("tmp1.mp4")
input2 = input("tmp2.mp4")
Expand Down

0 comments on commit 997592b

Please sign in to comment.