mirror of
https://github.com/sbrow/nu-ffmpeg.git
synced 2025-12-29 16:23:11 -05:00
fix: Fixed a bug where filterchains wouldn't append properly.
This commit is contained in:
32
ffmpeg.nu
32
ffmpeg.nu
@@ -33,18 +33,24 @@ export def "run" [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "append last" [
|
||||||
|
items: list
|
||||||
|
]: list -> list {
|
||||||
|
let list = $in;
|
||||||
|
|
||||||
|
($list | range 0..-2) | append [($list | default [] | last | append $items)]
|
||||||
|
}
|
||||||
|
|
||||||
export def "cmd filters append" [
|
export def "cmd filters append" [
|
||||||
complex_filter: list<record>
|
complex_filters: list<record>
|
||||||
]: record -> record {
|
]: record -> record {
|
||||||
update filters { |cmd|
|
update filters { |cmd|
|
||||||
let filters = $in;
|
let filters = $in;
|
||||||
|
|
||||||
if ($cmd.options.chain_filters) {
|
if ($cmd.options.chain_filters) {
|
||||||
(($filters | range 0..-2) | append [
|
$filters | append last $complex_filters
|
||||||
(($filters | default [] | last) | append $complex_filter)
|
|
||||||
])
|
|
||||||
} else {
|
} else {
|
||||||
$filters | append [$complex_filter]
|
$filters | append [$complex_filters]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +105,21 @@ export def filterchain [
|
|||||||
let original_option = $cmd.options.chain_filters;
|
let original_option = $cmd.options.chain_filters;
|
||||||
|
|
||||||
# TODO: Assign inputs and outputs
|
# TODO: Assign inputs and outputs
|
||||||
$cmd | update options.chain_filters { not $in } | do $filter | update options.chain_filters $original_option;
|
(
|
||||||
|
$cmd
|
||||||
|
| update options.chain_filters { not $in }
|
||||||
|
| update filters {
|
||||||
|
let it = $in;
|
||||||
|
|
||||||
|
if ($it | describe | str starts-with 'table') {
|
||||||
|
[$it [] ]
|
||||||
|
} else {
|
||||||
|
$it | append [[]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| do $filter
|
||||||
|
| update options.chain_filters $original_option
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build a record representaion of a complex filter
|
# Build a record representaion of a complex filter
|
||||||
|
|||||||
@@ -176,3 +176,54 @@ def filterchain_concats_filters [] {
|
|||||||
options: { chain_filters: false }
|
options: { chain_filters: false }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
def filterchain_appends_current_filter [] {
|
||||||
|
let got = (cmd ['INPUT'] ['OUTPUT'] | fps 12 | filterchain { fps 25 -i ['in'] | loop 2 1 -o ['out']});
|
||||||
|
|
||||||
|
assert equal $got {
|
||||||
|
input: ['INPUT']
|
||||||
|
filters: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
input: []
|
||||||
|
name: 'fps'
|
||||||
|
params: [
|
||||||
|
{param: 'fps' value: '12'}
|
||||||
|
]
|
||||||
|
output: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
[
|
||||||
|
{
|
||||||
|
input: ['in']
|
||||||
|
name: 'fps'
|
||||||
|
params: [
|
||||||
|
{param: 'fps' value: '25'}
|
||||||
|
]
|
||||||
|
output: []
|
||||||
|
}
|
||||||
|
#{
|
||||||
|
# input: []
|
||||||
|
# name: 'settb'
|
||||||
|
# params: [
|
||||||
|
# {param: 'expr' value: '1/25'}
|
||||||
|
# ]
|
||||||
|
# output: []
|
||||||
|
#}
|
||||||
|
{
|
||||||
|
input: []
|
||||||
|
name: 'loop'
|
||||||
|
params: [
|
||||||
|
{param: 'loop' value: 2}
|
||||||
|
{param: 'size' value: 1}
|
||||||
|
]
|
||||||
|
output: ['out']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
output: ['OUTPUT']
|
||||||
|
args: []
|
||||||
|
options: { chain_filters: false }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user