[FFmpeg-soc] [PATCH] Add fade filter to libavfilter

Víctor Paesa victorpaesa at googlemail.com
Wed Mar 31 19:32:20 CEST 2010


Hi,

On Wed, Mar 31, 2010 at 5:22 PM, Brandon Mintern <bmintern at gmail.com> wrote:
> On Wed, Mar 31, 2010 at 5:47 AM, Benoit Fouet <benoit.fouet at free.fr> wrote:
>> Hi,
>>
>> On Wed, 31 Mar 2010 00:43:50 -0400 Brandon Mintern wrote:
>>> I am happy to present my first-ever open source code contribution, a
>>> "fade" filter for libavfilter! Here is some example usage:
>>>
>>> # Fade in first 30 frames of video
>>> ffmpeg -i input.avi -vfilters fade=in:1:30 output.avi
>>>
>>> # Fade out last 45 frames of a 200-frame video
>>> ffmpeg -i input.avi -vfilters fade=out:156:45 output.avi
>>>
>>> # Fade in first 25 frames and fade out last 25 frames of a 1000-frame video
>>> ffmpeg -i input.avi -vfilters "fade=in:1:25, fade=out:976:25" output.avi
>>>
>>
>> Would it be possible to (also ?) make it work as follow ?
>> ffmpeg -i input -vfilters "fade=in:25, fade=out:25"
>>
>> That's to say: begin fade in at frame 0 and finish fade out at last frame.
>>
>> Ben
>
> The fade=in:25 is something I could do. Unfortunately the filter has
> no information regarding total number of frames until it reaches the
> end of the input stream (at least to my knowledge), so the fade=out:25
> would not work without buffering frames.

The ffmpeg that calls this filter knows the input duration (if not pipe,
stream, etc).
It would be nice if that information would be available for the filters.
Filters have an "opaque" parameter, but, currently, ffmpeg.c
is not using it.

> It should be
> somewhat-trivial, however, to use ffprobe or something similar
> beforehand in order to get the total duration and multiply that by the
> FPS in order to get the total frames in the video. That's the way I
> plan to do it.

Be aware that there containers with variable framerate (ASF, MP4, etc).

> Hmm... I just thought of an idea that should work. For fade=out we
> could buffer frame_length frames until we hit the end of the video,
> then start outputting the fading frames. Unfortunately, this is beyond
> my knowledge of libavfilter at the moment, and I would rather get this
> initial version accepted before adding more functionality to it. This
> is definitely something I will keep in mind though, because this seems
> to be how most people would like to use fade.
>
> On a sidenote, I see you referred to "frame 0". Is that standard in
> video processing? Should my 1-indexed frames instead be 0-indexed?

My preference is "frame 0" (it's my opinion, I'm not aware of a standard).

Regards,
Víctor


More information about the FFmpeg-soc mailing list