This will do it:
ffmpeg -i input.avi -vf "select='1-between(t,20,25)', setpts=N/FRAME_RATE/TB" -af "aselect='1-between(t,20,25)', asetpts=N/SR/TB" output.avi
This command will discard the segment from 20 seconds to 25 seconds and keep everything else. Instead of an exclusion list, you can also do an inclusion list like this:
ffmpeg -i input.avi -vf "select='lt(t,20)+between(t,790,810)+gt(t,1440)', setpts=N/FRAME_RATE/TB" -af "aselect='lt(t,20)+between(t,790,810)+gt(t,1440)', asetpts=N/SR/TB" output.avi
This will keep 3 segments of the original video (0-20 seconds, 790-810 seconds, and 1440-end seconds), while discarding anything else.
The key parts (of the second example, since it is more complicated):
-vf is the option for a video filter expression. We use the select filter, which will take an expression, evaluate it for each input frame, and keep the frame if the expression is 1, or discard it if the expression is 0. (There is actually a bit more nuance to this, but it isn't really relevant to your problem. Look here if you want to know the full story.)
lt(t,20) is the first part of the select filter expression. lt stands for less-than and t is the timestamp of the frame in seconds that is evaluated, so this will evaluate to 1 for any frame with t<20s
between(t,790,810) will evaluate to 1 for any frame between 790s and 810s
gt(t, 1440) (greater-than) will become 1 for any frame after 1440s
We then add all the conditions, to logically or them.
setpts=N/FRAME_RATE/TB is needed to provide us with the t value that we use in the logical expression. ffmpeg seems to think in samples/frames here, not in seconds, so we use this expression to convert to seconds.
-af is the option for an audio filter expression. The audio filter works analogous to the video filter, except that to convert to seconds, we use the sample rate SR of the audio, and not the FRAME_RATE of the video.
You can go crazy with the filter expression and add new segments by adding a between(t,...,...) term and combine terms as you need. The exclusion list you wanted simply utilizes the fact that we can invert our filter expression by subtracting it from 1, so everything discarded will now be kept, and vice versa.
Ensure that you have the same select filter for audio and video, or they will get out of sync!
Note that you won't be able to use -codec copy with this solution, since copy tells ffmpeg to not decode the video. Since the video filter is evaluated for decoded frames, we must decode first.