[FFmpeg-user] xmedian questions

Mark Filipak (ffmpeg) markfilipak at bog.us
Fri Jan 1 03:25:40 EET 2021


1, Median? Really? (Or maybe really average?)

For inputs = 239+15+15+15:
median = (239+15)/2 = 127
average = (239+15+15+15)/4 = 71
For inputs = 239+239+239+15:
median = (239+15)/2 = 127 (again)
average = (239+239+239+15)/4 = 183

Or is the median windowed?
For inputs = 239+15+15+15:
windowed median = ((239+15)/2+(15+15)/2)/2 = 71
For inputs = 239+239+239+15:
windowed median = ((239+239)/2+(239+15)/2)/2 = 183

Hmmm... Windowed median is actually average, isn't it?

1.1, If the number of inputs is odd, will the calculation skewed in favor of the final input in the 
windowed median calculation?) What is the real method that xmedian is using?

1.2, How does the value of 'percentile' figure into the calculations?

2, Why isn't "inputs=2" allowed?

 From ffmpeg.org/ffmpeg-filters.html#xmedian
=====
11.240 xmedian
Pick median pixels from several input videos.
The filter accepts the following options:
inputs
     Set number of inputs. Default is 3. Allowed range is from 3 to 255. If number of inputs is even 
number, than result will be mean value between two median values.
planes
     Set which planes to filter. Default value is 15, by which all planes are processed.
percentile
     Set median percentile. Default value is 0.5. Default value of 0.5 will pick always median 
values, while 0 will pick minimum values, and 1 maximum values.
=====


For what it's worth, here's how I document it:

xmedian   ...Pick median pixel values from several video streams.
xmedian=inputs=3:planes=15:percentile=0.5"   ...defaults
                |        |              |
                |        |              value to pick = max..median..min (1..0.5..0)
                |        color planes to pick = red+green+blue+alpha (sum of 1+2+4+8)
                number of input streams = 3..255

Of course, "value to pick = max..median..min (1..0.5..0)" is insufficient, isn't it?


More information about the ffmpeg-user mailing list