[FFmpeg-devel] [Patch][GSoC] Motion Estimation filter

Davinder Singh ds.mudhar at gmail.com
Sat Apr 9 21:03:40 CEST 2016

here's the new patch.

changes: fixed bugs, added documentation
added a step option, by default, while searching for macro-block, it moves
by 1 px in search area. this can be increased now.
uses absolute values instead of squares.
vector starts from center of macro-block, before it was at top-left.

There were a lot of "Past duration 0.999992 too large" warnings each frame
while encoding, perhaps its because the frame lags by 1 (as I store the
requested frame in MEContext->next)
this is fixed by changing: out_frame->pts = MEContext->next->pts

details of the filter:
The current filter is most basic block estimation technique which does full
search, which makes it quite slow, speed depends on the search area in
which the block is searched and it is independent of the block size. if we
take N x N block size, and video is W x H. Then total no of blocks will be
WxH / N^2. if R is search parameter then the no of places block is
searched: (2R + 1)^2, and for each block there will be N^2 iterations (for
comparing each pixel value which gives MAD. the one with minimum MAD is
used to get MV), so for all blocks in a frame, there will be WxH/N^2 *
(2R+1)^2*N^2 iterations = WxH * (2R+1)^2 iterations.
e.g. for a 720p video, R = 7 it will be 1280*720*15^2 = 207360000 iteration
per frame.

The current implementation only use first plane (luma) for estimation.

Obviously I have to implement a faster algorithm, I chose this one for


"We are merely explorers of infinity, in the pursuit of absolute perfection"

On Tue, Apr 5, 2016 at 12:25 AM Michael Niedermayer <michael at niedermayer.cc>

> [...]

missing documentation
> ive tested it as in
> ./ffplay matrixbench_mpeg2.mpg -vf mestimate=16,codecview=mv=7
> or
> ./ffplay ~/videos/matrixbench_mpeg2.mpg -vf mestimate=16:32,codecview=mv=7
> the vectors do not seem to represent motion, they all point in the
> same direction more or less
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-added-motion-estimation-filter.patch
Type: application/octet-stream
Size: 10870 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160409/b6d26953/attachment.obj>

More information about the ffmpeg-devel mailing list