[FFmpeg-user] Using the "select" filter

Tim Nicholson tim.nicholson at bbc.co.uk
Fri Nov 18 12:06:12 CET 2011

On 17/11/11 19:10, Clément Bœsch wrote:
> On Thu, Nov 17, 2011 at 08:09:40PM +0100, Clément Bœsch wrote:
>> On Thu, Nov 17, 2011 at 11:19:48AM +0000, Tim Nicholson wrote:
>>> The examples of using the select filter given at:-
>>> http://ffmpeg.org/ffmpeg.html#select
>>> suggest, for example,
>>> # select only I-frames
>>> select='eq(pict_type\,I)'
>>> However when I tried this I got an error.
>>> ffmpeg -i in.mp4 -vf "select='eq(pict_type\,I)', showinfo" -f mp4 -y
>>> /dev/null
>>> [..]
>>> Missing ')' or too many args in 'eq(pict_type\,I)'
>>> Removing the "\" which I assume is there to "escape" the comma
>>> solved the problem, thus:-
>>> ffmpeg -i in.mp4 -vf "select='eq(pict_type,I)', showinfo" -f mp4 -y
>>> /dev/null
>>> This looks like a small error in the docs.
>> You are not supposed to add quotes around the select.

The quotes were around the whole filtergraph, not just the select.

>>    ffmpeg -i in.mp4 -vf select='eq(pict_type,I)',showinfo -f ...
> Erh. I meant:
>     ffmpeg -i in.mp4 -vf select='eq(pict_type,\I)',showinfo -f ...

Actually you meant:-

ffmpeg -i in.mp4 -vf select='eq(pict_type\,I)', showinfo -f ...

Why is select different to any other filter?

Looking through the list of examples provided in:-


shows the following:-
23.11 fieldorder
ffmpeg -i in.vob -vf "fieldorder=bff" out.dv

23.16 hflip
ffmpeg -i in.avi -vf "hflip" out.avi

23.34 slicify
ffmpeg -i in.avi -vf "slicify=32" out.avi

23.37 unsharp
ffmpeg -i in.avi -vf "unsharp" out.mp4

23.38 vflip
ffmpeg -i in.avi -vf "vflip" out.avi

 From which one might reasonably deduce that is is normal, and 
recommended to enclose the whole filtergraph within " ". It certainly 
aids clarity in seeing what elements on the command line are part of the 
whole filter arrangement, and I think its more readable when you don't 
end up with \ escapes littering a filter that already has ample use of 
other punctuation characters such as = , : it reminds me a bit of perl. ;P

Of course its not actually that select is any different. Its just that 
when building a filtergraph you have the choice of either escaping 
individual characters as required, or enclosing the whole filtergraph in 
quotes, and it just happens that the select example is given using the 
alternative method, as are 4 other filters so in terms of examples its a 
dead heat!

However the inconsistency can be confusing, especially as the either/or 
nature of fully quoting or escaping is not mentioned in the general 
filtergraph description, with the -vf " " syntax only appearing in the 
above listed examples.


This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

More information about the ffmpeg-user mailing list