More ffmpeg hell

Today I went to use the “mp” filter in ffmpeg (which I documented in another posting), and was told “no such filter”. (WTF!!??? @#$%@%^#%^&)

So I did a search and found that “mp” and “eq2” may have been removed and replaced with just “eq”. I haven’t found out definitively, but find no record of an “mp” filter in the FFMPEG documentation currently. There are also several other filters like “colorbalance” available, but I haven’t used them yet.

I tried porting my commands over to just the “eq” filter, but they may have rearranged the order of the elements because they didn’t work as they did previously. They didn’t bother to include any examples…

They also indicate that with the “eq” filter, you can specify with words what you want, such as contrast=0, but they give no examples of syntax, so I’m guessing. They also state “If the specified expression is not valid, it is kept at its current value”.

The old order was gamma:contrast:brightness:saturation:rg:gg:bg:weight

Defaults and ranges:
Contrast -2.0 to 2.0, default 0 (but I think it is default 1)
Brightness -2.0 to 2.0, default 0
Saturation 0 to 3, default 1
Gamma 0 to 10, default 1
Gamma r 0 to 10, default 1
Gamma g 0 to 10, default 1
Gamma b 0 to 10, default 1

Here are some tests. I will update as I figure it out:

I think the new order is
contrast : brightness : saturation : gamma : gamma r : gamma g : gamma b : weight

But I’m not sure. If both brightness and contrast have a default of 0, then the following test makes no sense:

ffmpeg -i test.m2ts -vf eq=1:0:1:1:1:1:1:1 foo.mp4 makes no changes

ffmpeg -i test.m2ts -vf eq=1:0:0:1:1:1:1:1 foo.mp4 yields B&W (indicates the 3rd value is saturation)

I think that contrast has a default of 1, not 0.

Here is what I used to correct a green cast that I got from videoing under fluorescent lighting, and also boosts saturation:

ffmpeg -i all.m2ts  -vf eq=1:0:1.3:1:1:0.9:1:1 -c:v libx264 -c:a libfaac temp0.mp4

(That is the end of my tests. Sorry if you got a ton of notifications that I updated this post.)


5 thoughts on “More ffmpeg hell

  1. I figured out an experiment that might help confirm the order of the parameters.

    Run it several times with incrementally missing parameters, e.g. ‘ffmpeg … -vf eq=:: …’ yields this output:
    [Parsed_eq_0 @ 000000000331d980] [Eval @ 000000000022e890] Undefined constant or missing ‘(‘ in ”
    [Parsed_eq_0 @ 000000000331d980] Error when parsing the expression ” for contrast
    [AVFilterGraph @ 000000000347ff40] Error initializing filter ‘eq’ with args ‘::’
    Error opening filters!

    Therefore, contrast is the first parameter. Etc… Looks so far like you are right. Thanks!!

  2. Pingback: Adjusting video contrast, brightness, saturation, and color balance with FFMPEG | Computer Geekery

  3. Great article Jason. Its very helpful. I am using this for processing some videos for an experiment. But I have a query regarding the actual meanings of the value that corresponds to eq values. For example, given the brightness range is (-2,2), does making the brightness value = -1 reduce the brightness by 50%? Also, is this scale linear?

    Thank you!!!

  4. While you may be able to use the unnamed syntax as you present here, you can also use the following named syntax that makes it easier and reduces guessing:

    -vf “eq=contrast=1.25:brightness=.05:saturation=2.5:gamma_r=1.07:gamma_g=1:gamma_b=.885:gamma=1.08”

    Of course, this new syntax isn’t compatible with older scripts, but it would be relatively simple to upgrade these parameters to include names. At least with names, you know exactly what you’re setting.

    You can also use ffplay on a jpeg to preview your equalizer settings before you run it against your video input:

    ffplay -i input.jpg -vf “eq=contrast=1.25:brightness=.05:saturation=2.5”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s