[FFmpeg-devel] [PATCH 0/1] New helper expr for the select filter

bmathew at gmail.com bmathew at gmail.com
Mon Feb 5 23:48:44 EET 2018

Added a new expr/function get(n, filename) in libavutil/eval.c that is meant to
be used in conjunction with the select filter and greatly enhances the
generality of the select filter.

The select filter as it exists now can be used to selectively enable frames
during transcoding.  e.g.: select='not(mod(n\,100))' will enable one frame every

It is often required to do much more complex frame by frame selection under the
control of an external program. For example, a face detector might indicate
frames on which certain individuals have been detected and we wish to get a
video with only frames where those individuals are present. Another example is
video of lab experiments synchronized with some external sensor and we wish to
extract the frames where the sensor detected some event.

The get operator may be used as follows:
-vf 'select=get(n\,"frame_select.en")'

frame_select.en is a file that contains 1 byte per frame of the input video.  It
can be generated by the external program (e.g.: a face detector, lab software
that processes sensor data). The get operator looks up the n-th byte in the file
and passes it on to select so that frames can be kept or deleted. Very general
editing operations can be realized by having an external program generate the
enable file.


New struct AVGetExprBuffer has been added that is used to load the contents of
the frame select file only when a get() expression is present. eval_expr() was
modified to return the appropriate frame enable value from the buffer.

No changes to the libavutil API. The changes are completely contained within

 libavutil/eval.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 116 insertions(+), 2 deletions(-)


More information about the ffmpeg-devel mailing list