Body: <p>I needed to correct video illumination and found an awesome filter  called <a href="https://ffmpeg.org/ffmpeg-filters.html#greyedge" rel="nofollow noreferrer">greyedge</a>.</p>
  
  <p>The problem is that when applying this filter to my videos it often produces black frames. So I've made a test to make it easy to explain my problem:</p>
  
  <ol>
  <li>Take any png picture (I used one exported from my video - cut.png)</li>
  <li>Run <code>ffmpeg -y -i cut.png -vf greyedge=difford=1:minknorm=5:sigma=2 output.png</code>. On a first run it will produce black pic, on a second run it may or may not produce proper pic. On a third run it will give me correct picture. If I wait for some time and run it again - it will again produce black pic.</li>
  </ol>
  
  <p>Do you have any ideas why this might be happening? I'm suspecting some environment problem but maybe it's something known?</p>
  
  <p>Thank you.</p>
  
  <p>----- added logs ------</p>
  
  <p>Hey guys, yeah I understand it would work on your machines. It worked for me too, but then suddenly stopped. Here's the log (tried with my cut.mp4 file which worked well just a week ago):</p>
  
  <pre><code>ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
    built with Apple clang version 11.0.0 (clang-1100.0.33.16)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
    libavutil      56. 31.100 / 56. 31.100
    libavcodec     58. 54.100 / 58. 54.100
    libavformat    58. 29.100 / 58. 29.100
    libavdevice    58.  8.100 / 58.  8.100
    libavfilter     7. 57.100 /  7. 57.100
    libavresample   4.  0.  0 /  4.  0.  0
    libswscale      5.  5.100 /  5.  5.100
    libswresample   3.  5.100 /  3.  5.100
    libpostproc    55.  5.100 / 55.  5.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cut.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      creation_time   : 2020-01-12T01:16:55.000000Z
    Duration: 00:00:35.02, start: 0.000000, bitrate: 11644 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 9998 kb/s, 28.61 fps, 29.97 tbr, 90k tbn, 1411200000.00 tbc (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Video
      Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Audio
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (h264 (native) -&gt; h264 (libx264))
    Stream #0:1 -&gt; #0:1 (aac (native) -&gt; aac (native))
  Press [q] to stop, [?] for help
  [swscaler @ 0x107493000] No accelerated colorspace conversion found from yuv420p to gbrp.ed=N/A    
  [libx264 @ 0x7ffc1180ac00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 0x7ffc1180ac00] profile High, level 4.0
  [libx264 @ 0x7ffc1180ac00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'output.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      encoder         : Lavf58.29.100
      Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Video
        encoder         : Lavc58.54.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Audio
        encoder         : Lavc58.54.100 aac
  frame= 1050 fps=1.3 q=-1.0 Lsize=     664kB time=00:00:35.03 bitrate= 155.2kbits/s dup=53 drop=0 speed=0.0419x    
  video:75kB audio:550kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.241971%
  [libx264 @ 0x7ffc1180ac00] frame I:5     Avg QP: 7.60  size:   424
  [libx264 @ 0x7ffc1180ac00] frame P:265   Avg QP:10.09  size:    77
  [libx264 @ 0x7ffc1180ac00] frame B:780   Avg QP:13.67  size:    69
  [libx264 @ 0x7ffc1180ac00] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
  [libx264 @ 0x7ffc1180ac00] mb I  I16..4: 100.0%  0.0%  0.0%
  [libx264 @ 0x7ffc1180ac00] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
  [libx264 @ 0x7ffc1180ac00] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%
  [libx264 @ 0x7ffc1180ac00] 8x8 transform intra:0.0%
  [libx264 @ 0x7ffc1180ac00] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
  [libx264 @ 0x7ffc1180ac00] i16 v,h,dc,p: 99%  0%  1%  0%
  [libx264 @ 0x7ffc1180ac00] i8c dc,h,v,p: 100%  0%  0%  0%
  [libx264 @ 0x7ffc1180ac00] Weighted P-Frames: Y:0.0% UV:0.0%
  [libx264 @ 0x7ffc1180ac00] kb/s:17.36
  [aac @ 0x7ffc12807200] Qavg: 169.519
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-21T04:51:48.383Z
Comments.Text: Can't reproduce. Share full log and ideally input with which this issue occurs.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-21T08:38:37.763Z
Comments.Text: I can't reproduce, too. I always got binary identical outputs for the same input image (I tried 3 different images).
Comments.UserDisplayName: MarianD
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-24T00:37:13.057Z
Comments.Text: I've added log guys, sadly it worked for me too, but then something changed probably in my environment and it only produces black frames now :(
Comments.UserDisplayName: Andrii Gorishnii
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-24T15:06:08.657Z
Comments.Text: Try on another machine.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-27T00:23:00.303Z
Comments.Text: Yeah, it worked on my Windows machine. Still doesn't work on Mac...
Comments.UserDisplayName: Andrii Gorishnii
Tags: <ffmpeg>
Title: FFMPEG greyedge filter randomly produces black frames
UserDisplayName: Andrii Gorishnii
ThreadText: # FFMPEG greyedge filter randomly produces black frames
  
  (Asked by: username_0 on 2020-01-21)
  
  I needed to correct video illumination and found an awesome filter called [greyedge](https://ffmpeg.org/ffmpeg-filters.html#greyedge).
  
  The problem is that when applying this filter to my videos it often produces black frames. So I've made a test to make it easy to explain my problem:
  
  1. Take any png picture (I used one exported from my video - cut.png)
  2. Run `ffmpeg -y -i cut.png -vf greyedge=difford=1:minknorm=5:sigma=2 output.png`. On a first run it will produce black pic, on a second run it may or may not produce proper pic. On a third run it will give me correct picture. If I wait for some time and run it again - it will again produce black pic.
  
  Do you have any ideas why this might be happening? I'm suspecting some environment problem but maybe it's something known?
  
  Thank you.
  
  ----- added logs ------
  
  Hey guys, yeah I understand it would work on your machines. It worked for me too, but then suddenly stopped. Here's the log (tried with my cut.mp4 file which worked well just a week ago):
  
  ```
  ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
    built with Apple clang version 11.0.0 (clang-1100.0.33.16)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
    libavutil      56. 31.100 / 56. 31.100
    libavcodec     58. 54.100 / 58. 54.100
    libavformat    58. 29.100 / 58. 29.100
    libavdevice    58.  8.100 / 58.  8.100
    libavfilter     7. 57.100 /  7. 57.100
    libavresample   4.  0.  0 /  4.  0.  0
    libswscale      5.  5.100 /  5.  5.100
    libswresample   3.  5.100 /  3.  5.100
    libpostproc    55.  5.100 / 55.  5.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cut.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      creation_time   : 2020-01-12T01:16:55.000000Z
    Duration: 00:00:35.02, start: 0.000000, bitrate: 11644 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 9998 kb/s, 28.61 fps, 29.97 tbr, 90k tbn, 1411200000.00 tbc (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Video
      Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Audio
  Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Stream #0:1 -> #0:1 (aac (native) -> aac (native))
  Press [q] to stop, [?] for help
  [swscaler @ 0x107493000] No accelerated colorspace conversion found from yuv420p to gbrp.ed=N/A    
  [libx264 @ 0x7ffc1180ac00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 0x7ffc1180ac00] profile High, level 4.0
  [libx264 @ 0x7ffc1180ac00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'output.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      encoder         : Lavf58.29.100
      Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Video
        encoder         : Lavc58.54.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        creation_time   : 2020-01-12T01:16:55.000000Z
        handler_name    : Core Media Audio
        encoder         : Lavc58.54.100 aac
  frame= 1050 fps=1.3 q=-1.0 Lsize=     664kB time=00:00:35.03 bitrate= 155.2kbits/s dup=53 drop=0 speed=0.0419x    
  video:75kB audio:550kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.241971%
  [libx264 @ 0x7ffc1180ac00] frame I:5     Avg QP: 7.60  size:   424
  [libx264 @ 0x7ffc1180ac00] frame P:265   Avg QP:10.09  size:    77
  [libx264 @ 0x7ffc1180ac00] frame B:780   Avg QP:13.67  size:    69
  [libx264 @ 0x7ffc1180ac00] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
  [libx264 @ 0x7ffc1180ac00] mb I  I16..4: 100.0%  0.0%  0.0%
  [libx264 @ 0x7ffc1180ac00] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
  [libx264 @ 0x7ffc1180ac00] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%
  [libx264 @ 0x7ffc1180ac00] 8x8 transform intra:0.0%
  [libx264 @ 0x7ffc1180ac00] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
  [libx264 @ 0x7ffc1180ac00] i16 v,h,dc,p: 99%  0%  1%  0%
  [libx264 @ 0x7ffc1180ac00] i8c dc,h,v,p: 100%  0%  0%  0%
  [libx264 @ 0x7ffc1180ac00] Weighted P-Frames: Y:0.0% UV:0.0%
  [libx264 @ 0x7ffc1180ac00] kb/s:17.36
  [aac @ 0x7ffc12807200] Qavg: 169.519
  
  ```
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Can't reproduce. Share full log and ideally input with which this issue occurs.  
  > **username_2**: I can't reproduce, too. I always got binary identical outputs for the same input image (I tried 3 different images).  
  > **username_0**: I've added log guys, sadly it worked for me too, but then something changed probably in my environment and it only produces black frames now :(  
  > **username_1**: Try on another machine.  
  > **username_0**: Yeah, it worked on my Windows machine. Still doesn't work on Mac...  
  
  ---
  
  ## 0 answers
  
  