3

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.

#!/bin/bash

fn="$1"
of=${fn%.*}.jpg

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
0

1 Answer 1

0

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, privacy policy and cookie policy

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