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

Brandon Mintern bmintern at gmail.com
Wed Mar 31 17:22:06 CEST 2010


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. 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.

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?

Brandon


More information about the FFmpeg-soc mailing list