Opened 9 years ago
Closed 8 years ago
#5397 closed defect (fixed)
Incorrect curves filter work
Reported by: | Ilya87 | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avfilter |
Version: | git-master | Keywords: | curves |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | yes |
Description
Summary of the bug: curves video filter provides much darker picture than it should be
How to reproduce:
% ffplay "curves.mkv" -vf curves=r='0.037516/0':g='0.040103/0':b='0.059508/0' Result - FFmpeg colours are much darker than in Gimp. ffmpeg version N-79087-gefa98cd built on x86_64 Arch Linux
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Attachments (11)
Change History (22)
by , 9 years ago
Attachment: | ffmpeg_dark.png added |
---|
comment:2 by , 9 years ago
At least a command line together with complete, uncut console output is missing. Please only use FFplay to report issues if the issue is not reproducible with FFmpeg (the application).
comment:3 by , 9 years ago
Ok. Result is the same:
ffmpeg -i "curves.mkv" -pix_fmt yuv420p -vf curves=r='0.037516/0':g='0.040103/0':b='0.059508/0' -c:v libx264 -preset ultrafast -qp 0 output.mkv
ffmpeg version N-79273-gd433623 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --enable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 20.100 / 55. 20.100
libavcodec 57. 34.100 / 57. 34.100
libavformat 57. 31.100 / 57. 31.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 41.100 / 6. 41.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from 'curves.mkv':
Metadata:
ENCODER : Lavf57.28.102
Duration: 00:00:03.42, start: 0.000000, bitrate: 1049 kb/s
Chapter #0:0: start 0.000000, end 2.000000
Metadata:
title : Chapter 01
Stream #0:0(jpn): Video: h264 (High), yuv420p, 720x384 [SAR 1:1 DAR 15:8], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : Encoded by zdzdz
DURATION : 00:00:03.419000000
File 'output.mkv' already exists. Overwrite ? [y/N] y
[libx264 @ 0x5640bff4bb60] using SAR=1/1
[libx264 @ 0x5640bff4bb60] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x5640bff4bb60] profile High 4:4:4 Predictive, level 3.0, 4:2:0 8-bit
[libx264 @ 0x5640bff4bb60] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to 'output.mkv':
Metadata:
encoder : Lavf57.31.100
Chapter #0:0: start 0.000000, end 2.000000
Metadata:
title : Chapter 01
Stream #0:0(jpn): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 720x384 [SAR 1:1 DAR 15:8], q=-1--1, 23.98 fps, 1k tbn, 23.98 tbc (default)
Metadata:
title : Encoded by zdzdz
DURATION : 00:00:03.419000000
encoder : Lavc57.34.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Press [q] to stop, ? for help
frame= 82 fps=0.0 q=-1.0 Lsize= 4257kB time=00:00:03.42 bitrate=10196.7kbits/s speed= 16x
video:4255kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.035616%
[libx264 @ 0x5640bff4bb60] frame I:1 Avg QP: 0.00 size:154166
[libx264 @ 0x5640bff4bb60] frame P:81 Avg QP: 0.00 size: 51887
[libx264 @ 0x5640bff4bb60] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x5640bff4bb60] mb P I16..4: 5.3% 0.0% 0.0% P16..4: 82.9% 0.0% 0.0% 0.0% 0.0% skip:11.8%
[libx264 @ 0x5640bff4bb60] coded y,uvDC,uvAC intra: 79.5% 73.8% 73.6% inter: 71.3% 75.1% 73.9%
[libx264 @ 0x5640bff4bb60] i16 v,h,dc,p: 59% 38% 2% 1%
[libx264 @ 0x5640bff4bb60] i8c dc,h,v,p: 30% 34% 36% 0%
[libx264 @ 0x5640bff4bb60] kb/s:10191.59
comment:8 by , 8 years ago
Analyzed by developer: | set |
---|---|
Reproduced by developer: | set |
Status: | new → open |
A patch can be found at http://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/196740.html
Note that the curves in Gimp and Photoshop doesn't behave the same at all.
After the patch is applied, in order to get a close behavior to what you expect, you will have to use something like -vf curves=r='0.037516/0 1/1':g='0.040103/0 1/1':b='0.059508/0 1/1'
. If you define points in (0;0)
(-vf curves=r='0/0 0.037516/0 1/1':g='0/0 0.040103/0 1/1':b='0/0 0.059508/0 1/1'
), the curves will be much curvy at the origin and you will get your unexpected darker output. This doesn't happen in Gimp but is closer to what you observe in Photoshop. I will attach screenshot of Gimp and PS to show this.
Edit: see in particular curves-ps-3pts-31.png
vs curves-gimp-3pts-31.png
. To mimic Gimp behaviour, you will have to use 2 points instead of 3, see curves-ps-2pts-31.png
vs curves-gimp-2pts-31.png
by , 8 years ago
Attachment: | curves-gimp-2pts-31.png added |
---|
Curves Gimp with 2 points (31;0) and (255;255)
by , 8 years ago
Attachment: | curves-ps-2pts-31.png added |
---|
Curves PS with 2 points (31;0) and (255;255)
by , 8 years ago
Attachment: | curves-gimp-3pts-31.png added |
---|
Curves Gimp with 3 points (0;0), (31;0) and (255;255)
by , 8 years ago
Attachment: | curves-ps-3pts-31.png added |
---|
Curves PS with 3 points (0;0), (31;0) and (255;255)
follow-up: 10 comment:9 by , 8 years ago
And what if I define not only 2 points (start point 0.037516/0 and 1/1) on channel, but more? For example,
-vf curves=r='0.037516/0 0.127516/0.4 1/1'
Will it work in Gimp-style?
comment:10 by , 8 years ago
Replying to Ilya87:
And what if I define not only 2 points (start point 0.037516/0 and 1/1) on channel, but more? For example,
-vf curves=r='0.037516/0 0.127516/0.4 1/1'Will it work in Gimp-style?
Unfortunately no. It matches Photoshop behavior. I'm attaching 3 new images so you can compare the 3 tools. But basically, you can assume FFmpeg always matches Photoshop.
Also, you can try this branch: https://github.com/ubitux/FFmpeg/compare/curves (note to future reader: if this branch doesn't exist anymore, it's probably merged upstream).
Commit 2/2 of this branch adds a "plot" option you can use to get the curves used by FFmpeg. Quoting the example from the documentation:
ffmpeg -f lavfi -i color -vf curves=cross_process:plot=/tmp/curves.plt -frames:v 1 -f null - gnuplot -p /tmp/curves.plt
by , 8 years ago
Attachment: | 3pts-nz-photoshop.2.png added |
---|
3 points, not starting at zero, FPhotoshop
comment:11 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fixed in 5c14018fc4f6ae9fcce7eaf8dd2d66cb6fbfc7bc
Plot option added in 4a8f5f1fd83dfa92e02901e543d79124c4e551dc
(Bonus 16-bit support in e30cdac14b55ef290e26e055a88055ba9cde2f46)
Thanks for the report.
ffmpeg version