# extrastereo¶

doc

https://ffmpeg.org/ffmpeg-filters.html#extrastereo

The description in the official documentation:

Linearly increases the difference between left and right channels which adds some sort of “live” effect to playback.

Each segment of the uploaded video was created with the following script:

#! /bin/sh
ffmpeg -hide_banner -y -filter_complex "
aevalsrc='
0.1 * (
sin(2*PI * 130.81278265 * t)
+ sin(2*PI * 195.99771799 * t)) |
0.1 * (
sin(2*PI * 164.81377846 * t)
+ sin(2*PI * 195.99771799 * t))':d=10
, extrastereo=m=0.5
, aformat=sample_fmts=u8|s16:channel_layouts=stereo
, asplit=3[out1][a1][a2];
[a1]channelsplit[a11][a12];
[a11]showcqt=s=960x270,crop=480:270:0,setsar=1[v1];
[a12]showcqt=s=960x270,crop=480:270:0,setsar=1,vflip[v2];
[a2]showwaves=mode=line:s=480x540:split_channels=1,setsar=1[vR];
[v1][v2]vstack[vL];
[vL][vR]hstack
, format=yuv420p
, scale=1280:720
[out0]" -map '[out0]' -map '[out1]' out.mp4

The official documents says that this filter linearly increases the difference between left and right channels. This explanation and the actual behavior is quite difficult to understand, but if you want to understand exactly what this filter does, it is quick to read the source code (af_extrastereo.c):

af_extrastereo.c
left    = src[n * 2    ];
right   = src[n * 2 + 1];
average = (left + right) / 2.;
left    = average + mult * (left  - average);
right   = average + mult * (right - average);

if (s->clip) {
left  = av_clipf(left,  -1, 1);
right = av_clipf(right, -1, 1);
}

Therefore, if the absolute value of “mult” is smaller than 1, the difference is reduced, and if it is larger than 1, the difference is amplified:

[me@host: ~]$ffplay -f lavfi "aevalsrc=' > 0.1 * ( > sin(2*PI * 130.81278265 * t) > + sin(2*PI * 195.99771799 * t)) | > 0.1 * ( > sin(2*PI * 164.81377846 * t) > + sin(2*PI * 195.99771799 * t))':d=10 > , extrastereo=m=0.5" [me@host: ~]$ ffplay -f lavfi "aevalsrc='
> 0.1 * (
>   sin(2*PI * 130.81278265 * t)
> + sin(2*PI * 195.99771799 * t)) |
> 0.1 * (
>   sin(2*PI * 164.81377846 * t)
> + sin(2*PI * 195.99771799 * t))':d=10
> , extrastereo=m=1.5"

What this filter does is actually just one particular pattern of what a pan filter can do. The same thing isn’t “easy to write” using the pan filter, but similar things can be easily achieved.

[me@host: ~]\$ ffplay -f lavfi "aevalsrc='
> 0.1 * (
>   sin(2*PI * 130.81278265 * t)
> + sin(2*PI * 195.99771799 * t)) |
> 0.1 * (
>   sin(2*PI * 164.81377846 * t)
> + sin(2*PI * 195.99771799 * t))':d=10
> , pan='stereo|
>   c0 < 0.333 * c0 + 0.667 * c1 |
>   c1 < 0.667 * c0 + 0.333 * c1'"