ffmpeg: Apply a time-based expression to control lowpass, highpass, aphaser, or aecho

I am constructing complexFilters to procedurally generate audio with ffmpeg via fluent-ffmpeg. The interesting part of my fluent-ffmpeg complex filters look like:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"filter": "volume",
"options": {
"volume": "min(1, max(0, ((cos(PI * t * 1 / 13) * 1 + cos(PI * t * 1 / 7) * 0.5 + cos(PI * t * 1 / 3) * 0.25) +
-0.5 ) * 0.75 * -1 + 0.5))",
"eval": "frame"
},
"inputs": "track_1_output",
"outputs": "track_1_adjusted"
},
</code>
<code>{ "filter": "volume", "options": { "volume": "min(1, max(0, ((cos(PI * t * 1 / 13) * 1 + cos(PI * t * 1 / 7) * 0.5 + cos(PI * t * 1 / 3) * 0.25) + -0.5 ) * 0.75 * -1 + 0.5))", "eval": "frame" }, "inputs": "track_1_output", "outputs": "track_1_adjusted" }, </code>
{
   "filter": "volume",
   "options": {
       "volume": "min(1, max(0, ((cos(PI * t * 1 / 13) * 1 + cos(PI * t * 1 / 7) * 0.5 + cos(PI * t * 1 / 3) * 0.25) +
-0.5 ) * 0.75 * -1 + 0.5))",
       "eval": "frame"
    },
    "inputs": "track_1_output",
    "outputs": "track_1_adjusted"
},

Note that I am using an expression to determine the volume dynamically. To simplify my tests, I’m constructing complexFilters on the command line to understand the mysteries of some of the lightly-documented ffmpeg filters. Here’s a working CLI test of using the volume filter to fade the sources in and out according to a time-based expresssion:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># working fade in/out
ffmpeg -i knox.mp3 -i static.mp3 -filter_complex
"[0:a]
volume = 'min(1, max(0, 0.5 + 0.5 * cos(PI * t / 5)))': eval=frame
[a0];
[1:a]
volume = 'min(1, max(0, 0.5 - 0.5 * cos(PI * t / 5)))': eval=frame
[a1];
[a0][a1]
amix = inputs=2: duration=shortest"
-c:a libmp3lame -q:a 2 output.mp3
</code>
<code># working fade in/out ffmpeg -i knox.mp3 -i static.mp3 -filter_complex "[0:a] volume = 'min(1, max(0, 0.5 + 0.5 * cos(PI * t / 5)))': eval=frame [a0]; [1:a] volume = 'min(1, max(0, 0.5 - 0.5 * cos(PI * t / 5)))': eval=frame [a1]; [a0][a1] amix = inputs=2: duration=shortest" -c:a libmp3lame -q:a 2 output.mp3 </code>
# working fade in/out
ffmpeg -i knox.mp3 -i static.mp3 -filter_complex 
"[0:a] 
    volume = 'min(1, max(0, 0.5 + 0.5 * cos(PI * t / 5)))': eval=frame 
    [a0]; 
[1:a] 
    volume = 'min(1, max(0, 0.5 - 0.5 * cos(PI * t / 5)))': eval=frame 
    [a1]; 
[a0][a1]
    amix = inputs=2: duration=shortest" 
-c:a libmp3lame -q:a 2 output.mp3

Now I want to apply lowpass, highpass, aphaser, and/or aecho to the transitions using a time-based expression. For instance, looking at lowpasss, according to ffmpeg -filters it says that it has time-based support:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> T.. = Timeline support
TSC lowpass A->A Apply a low-pass filter with 3dB point frequency.
</code>
<code> T.. = Timeline support TSC lowpass A->A Apply a low-pass filter with 3dB point frequency. </code>
  T.. = Timeline support
 TSC lowpass           A->A       Apply a low-pass filter with 3dB point frequency.

How can I similarly apply a time-based expression to lowpass, highpass, aphaser, or aecho? I thought the mix option might be the key, but I couldn’t construct a working example and couldn’t find any examples.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># applying a lowpass filter
ffmpeg -i knox.mp3 -filter_complex
"[0:a]
lowpass=f=3000:mix='0.5 + 0.5 * cos(PI * t / 5)';"
-c:a libmp3lame -q:a 2 output.mp3
</code>
<code># applying a lowpass filter ffmpeg -i knox.mp3 -filter_complex "[0:a] lowpass=f=3000:mix='0.5 + 0.5 * cos(PI * t / 5)';" -c:a libmp3lame -q:a 2 output.mp3 </code>
# applying a lowpass filter
ffmpeg -i knox.mp3 -filter_complex 
"[0:a] 
    lowpass=f=3000:mix='0.5 + 0.5 * cos(PI * t / 5)';" 
-c:a libmp3lame -q:a 2 output.mp3

Or if you prefer the fluent-ffmpeg filter:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const ffmpeg = require('fluent-ffmpeg');
ffmpeg('knox.mp3')
.complexFilter([
{
filter: 'lowpass',
options: {
f: 3000,
mix: '0.5 + 0.5 * cos(PI * t / 5)'
},
inputs: '[0:a]',
}
])
.audioCodec('libmp3lame')
.audioQuality(2)
.save('output.mp3')
.on('end', () => {
console.log('Processing finished successfully');
})
.on('error', (err) => {
console.error('Error: ' + err.message);
});
</code>
<code>const ffmpeg = require('fluent-ffmpeg'); ffmpeg('knox.mp3') .complexFilter([ { filter: 'lowpass', options: { f: 3000, mix: '0.5 + 0.5 * cos(PI * t / 5)' }, inputs: '[0:a]', } ]) .audioCodec('libmp3lame') .audioQuality(2) .save('output.mp3') .on('end', () => { console.log('Processing finished successfully'); }) .on('error', (err) => { console.error('Error: ' + err.message); }); </code>
const ffmpeg = require('fluent-ffmpeg');

ffmpeg('knox.mp3')
    .complexFilter([
        {
            filter: 'lowpass',
            options: {
                f: 3000,
                mix: '0.5 + 0.5 * cos(PI * t / 5)'
            },
            inputs: '[0:a]',
        }
    ])
    .audioCodec('libmp3lame')
    .audioQuality(2)
    .save('output.mp3')
    .on('end', () => {
        console.log('Processing finished successfully');
    })
    .on('error', (err) => {
        console.error('Error: ' + err.message);
    });

With the resultant error:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[Parsed_lowpass_1 @ 0x7f9a72005c00] [Eval @ 0x7ff7bec423d8] Undefined constant or missing '(' in 't/5)'
[Parsed_lowpass_1 @ 0x7f9a72005c00] Unable to parse option value "0.5 + 0.5 * cos(PI * t / 5)"
Error applying option 'mix' to filter 'lowpass': Invalid argument
</code>
<code>[Parsed_lowpass_1 @ 0x7f9a72005c00] [Eval @ 0x7ff7bec423d8] Undefined constant or missing '(' in 't/5)' [Parsed_lowpass_1 @ 0x7f9a72005c00] Unable to parse option value "0.5 + 0.5 * cos(PI * t / 5)" Error applying option 'mix' to filter 'lowpass': Invalid argument </code>
[Parsed_lowpass_1 @ 0x7f9a72005c00] [Eval @ 0x7ff7bec423d8] Undefined constant or missing '(' in 't/5)'
[Parsed_lowpass_1 @ 0x7f9a72005c00] Unable to parse option value "0.5 + 0.5 * cos(PI * t / 5)"
Error applying option 'mix' to filter 'lowpass': Invalid argument

What complicated fffmpeg faerie magic is needed to make some of the filters other than volume controlled by a time-based expr?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật