mirror of
https://github.com/sbrow/nu-ffmpeg.git
synced 2025-12-29 16:23:11 -05:00
feat: Filterchains can now be passed inputs and outputs.
This commit is contained in:
24
ffmpeg.nu
24
ffmpeg.nu
@@ -36,9 +36,7 @@ export def "run" [
|
|||||||
def "append last" [
|
def "append last" [
|
||||||
items: list
|
items: list
|
||||||
]: list -> list {
|
]: list -> list {
|
||||||
let list = $in;
|
update (($in | length) - 1) { $in | append $items }
|
||||||
|
|
||||||
($list | range 0..-2) | append [($list | default [] | last | append $items)]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export def "cmd filters append" [
|
export def "cmd filters append" [
|
||||||
@@ -97,8 +95,8 @@ def "filter to-string" []: record<input: list<string> name: string params: table
|
|||||||
|
|
||||||
# Set the input and outputs of a filter chain
|
# Set the input and outputs of a filter chain
|
||||||
export def filterchain [
|
export def filterchain [
|
||||||
#input: list<string>
|
--input (-i): list<string>
|
||||||
#output: list<string>
|
--output (-o): list<string>
|
||||||
filter: closure
|
filter: closure
|
||||||
] {
|
] {
|
||||||
let cmd = $in;
|
let cmd = $in;
|
||||||
@@ -118,6 +116,22 @@ export def filterchain [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
| do $filter
|
| do $filter
|
||||||
|
| if ($input | is-empty | not $in) {
|
||||||
|
update filters {
|
||||||
|
update (($in | length) - 1) {
|
||||||
|
update 0.input $input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { $in }
|
||||||
|
| if ($output | is-empty | not $in) {
|
||||||
|
update filters {
|
||||||
|
update (($in | length) - 1) {
|
||||||
|
update (($in | length) - 1) {
|
||||||
|
update output $output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { $in }
|
||||||
| update options.chain_filters $original_option
|
| update options.chain_filters $original_option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,3 +227,35 @@ def filterchain_appends_current_filter [] {
|
|||||||
options: { chain_filters: false }
|
options: { chain_filters: false }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
def filterchains_can_set_inputs_and_outputs [] {
|
||||||
|
let got = (cmd ['INPUT'] ['OUTPUT'] | filterchain -i ['in'] -o ['out'] { fps 25 | settb '1/25' });
|
||||||
|
|
||||||
|
assert equal $got {
|
||||||
|
input: ['INPUT']
|
||||||
|
filters: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
input: ['in']
|
||||||
|
name: 'fps'
|
||||||
|
params: [
|
||||||
|
{param: 'fps' value: '25'}
|
||||||
|
]
|
||||||
|
output: []
|
||||||
|
}
|
||||||
|
{
|
||||||
|
input: []
|
||||||
|
name: 'settb'
|
||||||
|
params: [
|
||||||
|
{param: 'expr' value: '1/25'}
|
||||||
|
]
|
||||||
|
output: ['out']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
output: ['OUTPUT']
|
||||||
|
args: []
|
||||||
|
options: { chain_filters: false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user