I am trying to delete the very last frame of a video using ffmpeg / mencoder / transcode / or any other free linux application.

Here is what I have so far, and it's only extracting it, it's not deleting it from the actual video file.



lf=`ffprobe -show_streams "$fn" 2> /dev/null | awk -F= '/^nb_frames/ { print $2-1 }'`
rm -f "$of"
ffmpeg -i "$fn" -vf "select='eq(n,$lf)'" -vframes 1 "$of" 2> /dev/null

1 Answer 1


Your first line, which attempts to get the number of frames does not work for me. For whatever reason my test files report 'N/A' rather than a number. But since it worked for you, you were almost done.

If you know that you want to remove frame number $lf, you can just do the following:

let frames=$lf-1
ffmpeg -i "$fn" -frames:v $frames -c:v copy -c:a copy "$of"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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