so i am using the following code to in a windows .BAT file to cut up a video at X time:

bin\ffmpeg -hide_banner -loglevel 0 -i "%video%" -c copy -map 0 -f segment -segment_time %segment_time% -reset_timestamps 1 -segment_format_options movflags=+faststart out%%03d.mp4

No issues there.

I then add a fade in and fade out to those segments using the following code:

for %%a in (out*.mp4) DO bin\ffmpeg -hide_banner -loglevel 0 -i "%%a" -vf "fade=t=in:st=%segment_fade_in%:d=%segment_fade_duration%,fade=t=out:st=%segment_fade_out%:d=%segment_fade_duration%" -af "afade=t=in:st=%segment_fade_in%:d=%segment_fade_duration%,afade=t=out:st=%segment_fade_out%:d=%segment_fade_duration%" -async 1 fade_%%~na.mp4 

again NO issue here at all

what i am finding is that it takes a lot of time to add these fade in and fade outs.

So i was thinking of then cutting each of the segments, for say 2-3 seconds at the front and end of the video file adding the fade in or the fade out and then just concat them back together.

not asking for the code but a method that would not take me days to work on only to find it wont work. looking to see if anyone has done similar to save time

on videos over 20-30 seconds or less its not that big of deal but when the videos in the folder are 5-24 minutes it has to be way faster to cut them up.

1 Answer 1


I would like to answer my own question.

One thing tho is the file is quite large (370+ lines) so i have added it to pastebin

FF Fader on Pastebin

A few Notes:

I had errors popping up if the cuts were certain lengths like on a 30 sec video and I wanted over 10 sec cuts it would work but toss up errors such as

Invalid number.  Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021).
Invalid number.  Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021).

this error would be cause form the calculations at lines: 218 to 229

lines 218 - 229 were added by another issue i found was if you did a 6 sec segments, the last cut was shorter than 2 seconds so if that was the case i would need to concat that way cause it was concating (sp?) that last clip twice

If that is not correct way of answering the question here, please help me fix it b4 down voting me etc. I am new here

I would love some input and if you see where it can be cleaned up that would be great too


Wanted to add that taking a 30 second video and cutting into 3 segments, then cutting those 3 segments into 3 sections. add the fade in and fade out and then combine them all back into segments took right at 30 seconds or less!

That is pretty awesome! I think maybe using "threads" on ffmpeg could speed it up but I am not sure you need it any faster than that. If you have a idea to speed up ffmpeg more let me know in the comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.