Basic info
This feature is available for MPlatform SDK. For MFormats, support for FFMPEG audio filter was introduced in version 2.10.0.14414 and is available exclusively in the Expert and Ultimate editions. FFMPEG audio filter offer advanced audio processing capabilities, allowing users to apply custom audio effects within the SDK framework.
You can use audio filters for FFmpeg to manage audio of your sources (files, network streams, cameras, etc). With the filters, you can control audio volume, filter noise and so on.
MFormats SDK
The usage of afilters in MFormats SDK is similar to working with plugins such as CG, MCCDisplay, etc. In general, it's needed to create a MFXMediaConverter instance, set its parameters, and during the frame processing pipeline, this converter processes each frame. Below is an example of how to add and apply the "volume" filter in MFormats SDK:
MFReaderClass m_objReader = new MFReaderClass();
MFPreviewClass m_objPreview = new MFPreviewClass();
MFXMediaConverter m_objConverter = new MFXMediaConverter();
m_objReader.ReaderOpen(pathToVideo, "");
m_objPreview.PreviewEnable("", 1, 1);
// "av_filter_graph_desc_out" - Apply audio filter after video processing (e.g. audio conversion)
// It's not possible to apply audio filter before audio processing. "av_filter_graph_desc_in" doesn't work.
String AFilter_ConvProps = @"{""av_filter_graph_desc_out"":""volume=-40dB""}";
(m_objConverter as IMFProps).PropsSet(@"audio::xmedia_conversion_props", AFilter_ConvProps);
M_AV_PROPS m_AV_PROPS = new M_AV_PROPS();
m_AV_PROPS.vidProps.eVideoFormat = eMVideoFormat.eMVF_Custom;
int rest = 0;
do
{
m_objReader.SourceFrameGet(-1, out MFFrame pFrame, "");
m_objConverter.ConverterFrameConvert("", pFrame, ref m_AV_PROPS, out var pFrameConverted, out rest, "");
Marshal.ReleaseComObject(pFrame);
if (pFrameConverted != null)
{
m_objPreview.ReceiverFramePut(pFrameConverted, -1, "");
Marshal.ReleaseComObject(pFrameConverted);
}
} while (rest > 0);Important Note! The MFXMediaConverter class is implemented exclusively for 64-bit environments. Therefore, the use of the MFXMediaConverter class and consequently, afilters are only supported in 64-bit applications.
MPlatform SDK
The property that you should set to enable an audio filter is "object::afilter" with PropsSet method for your object. For example:
myLive.PropsSet("object::afilter", "volume=2");If you use several filters in a chain then you should set them in a single value separating by commas:
myLive.PropsSet("object::afilter", "highpass=f=120,acompressor=threshold=0.3:makeup=3:release=50:attack=5:knee=4:ratio=10:detection=peak,alimiter=limit=0.95");Possible values
Filter name |
Filter effect description |
“object::afilter” value |
|---|---|---|
| acompressor | Audio compressor. |
acompressor
Test chain: acompressor=threshold=0.3:makeup=3:release=50: |
| acrusher | Reduce audio bit resolution. |
acrusher
Test chain: acrusher=bits=2 |
| adelay | Delay one or more audio channels. |
adelay
Test chain: adelay=1500|0 Delay first audio channel by 1.5 seconds and leave the second channel (and any other channels that may be present) unchanged.
|
| aecho | Add echoing to the audio. |
aecho
Test chain: aecho=0.8:0.88:60:0.4 Make it sound as if there are twice as many instruments as are actually playing |
| aemphasis | Audio emphasis. | aemphasis |
| aeval | Filter audio signal according to a specified expression. |
aeval
Test chain: aeval=val(0)|-val(1) Invert phase of the second channel |
| afade | Fade in/out input audio. | afade |
| agate | Audio gate. | agate |
| alimiter | Audio lookahead limiter. | alimiter |
| allpass | Apply a two-pole all-pass filter. | allpass |
| amerge | Merge two or more audio streams into a single multi-channel stream. | amerge |
| anequalizer | Apply high-order audio parametric multi band equalizer. | anequalizer |
| aphaser | Add a phasing effect to the audio. | aphaser |
| apulsator | Audio pulsator. | apulsator |
| bandpass | Apply a two-pole Butterworth band-pass filter. | bandpass |
| bandreject | Apply a two-pole Butterworth band-reject filter. | bandreject |
| bass | Boost or cut lower frequencies. | bass |
| biquad | Apply a biquad IIR filter with the given coefficients. | biquad |
| bs2b | Bauer stereo-to-binaural filter. | bs2b |
| chorus | Add a chorus effect to the audio. | chorus |
| compand | Compress or expand audio dynamic range. | compand |
| compensationdelay | Audio Compensation Delay Line. | compensationdelay |
| crossfeed | Apply headphone crossfeed filter. | crossfeed |
| crystalizer | Simple expand audio dynamic range filter. | crystalizer |
| dcshift | Apply a DC shift to the audio. | dcshift |
| earwax | Widen the stereo image. | earwax |
| equalizer | Apply two-pole peaking equalization (EQ) filter. | equalizer |
| extrastereo | Increase difference between stereo audio channels. | extrastereo |
| firequalizer | Finite Impulse Response Equalizer. | firequalizer |
| flanger | Apply a flanging effect to the audio. | flanger |
| has | Apply Haas Stereo Enhancer. | haas |
| highpass | Apply a high-pass filter with 3dB point frequency. | highpass |
| lowpass | Apply a low-pass filter with 3dB point frequency. | lowpass |
| pan | Remix channels with coefficients (panning). |
pan
Test chain: pan=1c|c0=0.9*c0+0.1*c1 |
| stereotools | Apply various stereo tools. |
stereotools
Test chain: stereotools=mlev=0.015625 |
| stereowiden | Apply stereo widening effect. | stereowiden |
| treble | Boost or cut upper frequencies. |
treble
Test chain: treble=10 |
| tremolo | Apply tremolo effect. | tremolo |
| vibrato | Apply vibrato effect. | vibrato |
| volume | Change input volume. | volume |