[FFmpeg-user] Problem: extracted alpha plane from a grayscale PNG is shifted by 1 pixel to the left

Carl Eugen Hoyos ceffmpeg at gmail.com
Sun Apr 7 03:39:06 EEST 2019


2019-04-07 2:17 GMT+02:00, Mikhail V <mikhailwas at gmail.com>:
> I have a strange problem with extracting alpha plane from an grayscale
> PNG with alpha channel.
> So I have an image with alpha in it and use this command:
>
> ffmpeg -i 1-open-patch.png  -vf alphaextract   -pix_fmt gray
> testgray_alpha.png
> or
> ffmpeg -i 1-open-patch.png  -vf alphaextract   testgray_alpha.png
> (wich works same way I think)
>
> Problem:  the output alpha plane is shifted 1 pixel to the left. The
> data is ok - but the position is 1 pixel shifted.
> The problem appears only with ya8 pixel format. If I use same but RGBa
> image the output plane is correctly positioned.

Please test the inlined patch.

Carl Eugen


diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c
index 739c242..2f2c8e1 100644
--- a/libavfilter/vf_extractplanes.c
+++ b/libavfilter/vf_extractplanes.c
@@ -226,6 +226,8 @@ static int config_input(AVFilterLink *inlink)
         for (i = 0; i < 4; i++)
             s->map[i] = rgba_map[s->map[i]];
     }
+    if (inlink->format == AV_PIX_FMT_GRAY8A)
+        s->map[0] = 1;

     return 0;
 }


More information about the ffmpeg-user mailing list