<p>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.</p>
<p>If you know that you want to remove frame number <code>$lf</code>, you can just do the following:</p>
<pre><code>let frames=$lf-1
ffmpeg -i &quot;$fn&quot; -frames:v $frames -c:v copy -c:a copy &quot;$of&quot;
</code></pre>

CC BY-SA 4.0
2021-11-30T13:14:16.157Z
2021-11-30T13:14:16.157Z
v010dya
<p>I am trying to delete the very last frame of a video using ffmpeg / mencoder / transcode / or any other free linux application.</p>

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

<pre><code>#!/bin/bash

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

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

<video><ffmpeg><encoding><script><command-line>
How to delete the very last frame of a video using ffmpeg / mencoder / transcode or any other?
Anonymous
# How to delete the very last frame of a video using ffmpeg / mencoder / transcode or any other?

(Asked by: username_0 on 2019-03-13)

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

**Tags:** video, ffmpeg, encoding, script, command-line


---

## 1 answers

### Answer by username_1 on 2021-11-30. Score: 2

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"


---

