[FFmpeg-user] Alpha not working as expected with geq filter
Paul B Mahol
onemda at gmail.com
Tue May 21 19:34:29 CEST 2013
On 5/21/13, Robert Krueger <krueger at lesspain.de> wrote:
> On Tue, May 21, 2013 at 6:56 PM, Paul B Mahol <onemda at gmail.com> wrote:
>> On 5/21/13, Robert Krueger <krueger at lesspain.de> wrote:
>>> Hi,
>>>
>>> I am trying to generate a test file using nullsrc and the geq filter
>>> to obtain an image that has color and alpha channel values defined by
>>> equations like so:
>>>
>>> ffmpeg -f lavfi -i nullsrc=s=256x256:d=0.01 -vf
>>> scale,geq='r=255*(X/W):g=255*(Y/H):b=255*((X/W)*(Y/H)):alpha_expr=255*(1-Y/H)'
>>> -pix_fmt rgba -y ~/tmp/generated-sd-alpha.png
>>>
>>> The generated png file does not contain any transparent pixels as far
>>> as I can see and I wonder what I have done wrong. I found trac ticket
>>> #2520 which has some similarities but it is marked as fixed. Full
>>> command line and output:
>>>
>>> ffmpeg -f lavfi -i nullsrc=s=256x256:d=0.01 -vf
>>> scale,geq='r=255*(X/W):g=255*(Y/H):b=255*((X/W)*(Y/H)):alpha_expr=255*(1-Y/H)'
>>> -pix_fmt rgba -y ~/tmp/generated-sd-alpha.png
>>> ffmpeg version N-53322-gb1bbd71 Copyright (c) 2000-2013 the FFmpeg
>>> developers
>>> built on May 21 2013 16:18:03 with llvm-gcc 4.2.1 (LLVM build
>>> 2336.11.00)
>>> configuration: --enable-gpl
>>> libavutil 52. 33.100 / 52. 33.100
>>> libavcodec 55. 10.101 / 55. 10.101
>>> libavformat 55. 7.100 / 55. 7.100
>>> libavdevice 55. 1.100 / 55. 1.100
>>> libavfilter 3. 68.101 / 3. 68.101
>>> libswscale 2. 3.100 / 2. 3.100
>>> libswresample 0. 17.102 / 0. 17.102
>>> libpostproc 52. 3.100 / 52. 3.100
>>> Input #0, lavfi, from 'nullsrc=s=256x256:d=0.01':
>>> Duration: N/A, start: 0.000000, bitrate: N/A
>>> Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256
>>
>> Input does not have any alpha, thus alpa can't be changed.
>
> I saw that but then I thought the geq filter would automatically use a
> format with alpha if an alpha expression was there, regardless of what
> was used in the previous member of the filter chain. Then I started
> looking for a way to force the source to have alpha. I tried
> - using -pix_fmt rgba as an input option but got an error message
> telling me that pixel format is an unsupported option
> - using color=0x80808080 as the source because I hoped setting an
> alpha value would somehow make it use a pixel format with alpha
> support
>
> So how do I force alpha to be there in the source other than
> generating a dummy video with alpha and using that as an input (which,
> of course I can do but I was looking for the more elegant solution
> first because I thought I must be missing some option to force a pixel
> format)?
Add format filter before geq filter, like this: -vf format=rgba,geq.....
More information about the ffmpeg-user
mailing list