Adapted from Cut video with ffmpeg:
ffmpeg -i input.mp3 -ss 4 -i input.mp3 -c copy -map 0:a -map 1:a -shortest -f nut - | ffmpeg -y -f nut -i - -c copy -map 0:0 output.mp3
What this does is uses the same input twice in a roundabout method to trim without needing to know duration and without re-encoding.
- The second input has 4 seconds cut off from the beginning.
- The
-shortest
option uses the shortest input duration to determine duration of the outputs. This results in cutting off the last 4 seconds from the first input to match the duration of the truncated second input. - Because both streams are needed for
-shortest
to work they are piped to another ffmpeg to remove the second input.