FFmpeg - trim beginning AND end fixed amounts

There's a sane way to do this and an insane way. The sane way is to probe the duration in a separate command beforehand and shape your actual trim command using that info.

Probe command:

ffprobe -v 0 -show_entries format=duration -of compact=p=0:nk=1 in.mp4

This will produce a single line output:

194.834000

So, your command is now

ffmpeg -ss 10 -t 174.834 -i test.mp4 outputB.mp4

where t = total duration - 20 sec


The insane way is slower, but one command.

ffmpeg -i in.mp4 -filter_complex
       "[0]split[s1][s2];
        [s1]trim=10,setpts=PTS-STARTPTS,fifo[bv];
        [s2]trim=10,setpts=(PTS-STARTPTS)+10/TB,fifo[v];
        [bv][v]overlay=shortest=1,trim=10,setpts=PTS-STARTPTS[fv];
        [0]volume=0[b];[0]adelay=10000|10000[a];
        [b][a]amix=duration=first,volume=2,atrim=20,asetpts=PTS-STARTPTS[fa]"
-map "[fv]" -map "[fa]" trimmed.mp4