I need a script to cut off the last 6 seconds of multiple videos. The videos do all have different length.
I can‘t find anything helpful online.
Does anyone know
You have to use a roundabout way to achieve this,
ffmpeg -i file.mp4 -itsoffset 6 \
-i file.mp4 -c copy -map 0:a:0 -map 1 \
-shortest -f nut - | \
ffmpeg -y -i - -c copy -map 0 -map -0:0 -ss 6 trimmed.mp4
This runs two ffmpeg processes connected by a pipe, although you can do it with two ffmpeg commands run one after the another.
The first command ingests the file twice and offsets the 2nd input's timestamps by 6 seconds. It maps an audio stream from the first input and all streams from the second. The output of the first command is set to terminate with the shortest stream, which is the audio stream from the first input. The side-effect is that the last 6 seconds of the 2nd input are chopped off. In the 2nd process, all streams except the first audio stream are copied into a new container.
If you're unsure whether a file has audio, you can replace -map 0:a:0
with -map 0:0