1

I just found out about FFMPEG and I need it to cut loads of MP4 files to the last 20 seconds of each. Each MP4 file has one video track and two audio tracks, and also have Variable Frame Rate.

I've been using this line of code:

for %F in (*.mp4) do ffmpeg -sseof -20 -i "%F" -map 0:v -map 0:a -c:v copy -c:a copy "%~nF_trimmed.mp4"

The trimming goes well but there's a problem with the audio. This error appears without canceling the trimming process, though I believe it has nothing to with my problem:

[mp4 @ 0000025740443740] track 1: codec frame size is not set
[mp4 @ 0000025740443740] track 2: codec frame size is not set

And when I drop the trimmed files to a video editing software, this can be seen:

Editor Screenshot

The second audio track is longer than the video track.

The -shortest command didn't do the trick. Maybe I'm just using it wrong?

2

I was messing around with -shortest and having issues with a longer audio track not being trimmed down to the length of the video. This is how I was trying to use it:

ffmpeg -i INPUT -c copy -shortest OUTPUT

After reading the documentation for the option a little more closely:

Finish encoding when the shortest input stream ends.

With the above FFmpeg command there is only a single input stream. So the following command finally worked:

ffmpeg -i INPUT -i INPUT -c copy -shortest -map 0:v -map 1:a OUTPUT

where both the INPUTs are the same file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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