[FFmpeg-user] ffmpeg video fade in fade out question

Gyan ffmpeg at gyani.pro
Sat Aug 24 12:57:05 EEST 2019



On 24-08-2019 02:08 PM, Stuart Foster via ffmpeg-user wrote:
> Hi,
>
> I am trying to build a command line that performs the following (all 
> values for example):
>
> Fast seek into the video sample 10 seconds, then slow seek for 5 
> seconds giving a start point for my new clip at 15 seconds.
> I then wish to have the clip start with 2 seconds of black followed by 
> a fade from black of 1 second.
> Similarly at the end of the clip I wish to fade to black for 1 second 
> followed by 2 seconds of black.
> From the seek point I require my total clip duration to be 20 seconds.
>
> Assuming what I require is possible on a single pass what would be the 
> correct values for t1 and t2 in the example give.
>
> From my experiments the values seem to be dependent on the seek and 
> duration parameters but I have not been able determine the exact 
> relationship.
>
> Example:
>
> linux ffmpeg version git-2019-06-08-b6ca032
>
> Test.mp4 : Duration: 00:10:00.05, start: 0.000000, bitrate: 280 kb/s
>
> ffmpeg -ss 10.000 -i Test.mp4 -ss 5.000 -t 20.000 -filter_complex 
> fade=type=in:duration=1:start_time=t1,fade=type=out:duration=1:start_time=t2 
> -y Test.avi
>
> Any suggestions ?

You could just do

     ffmpeg -ss 15 -i test.mp4 -vf 
"fade=type=in:start_time=2:duration=1,fade=type=out:start_time=17:duration=1" 
-t 20 outfile

since when transcoding a stream, ffmpeg inserts a trim filter to get an 
accurate seek when the seek point isn't a keyframe.

But if you want to use your original method, you can use

     ffmpeg -ss 10 -i test.mp4 -vf 
"trim=5:25,fade=type=in:start_time=7:duration=1,fade=type=out:start_time=22:duration=1,setpts=PTS-STARTPTS" 
-af "atrim=5:25,asetpts=PTS-STARTPTS" outfile


Gyan


More information about the ffmpeg-user mailing list