Body: <p>I tried to use many variations of syntax but with no viable results.</p>
  <p>The frames in the original file are 213214 and I want to omit the last frame for the total frames to become 213213 but when I try the below syntax I get a very weird result which a higher number of frames rather being decreased by 1</p>
  <pre><code>ffmpeg -copyts -i h:\dh.h265 -c copy -enc_time_base -1 -bsf:v:0 noise=drop='eq(pos\,213214)' h:\dh_framecorrect.mkv
  </code></pre>
  <p>so I tried this syntax</p>
  <pre><code>ffmpeg -i h:\dh.h265 -frames:v 213213 -c:v copy -c:a copy h:\dh_framecorrect.mkv
  </code></pre>
  <p>but again with no luck</p>
  <p>then I tried another syntax like in below</p>
  <pre><code>ffmpeg -copyts -i h:\dh.h265 -vf &quot;select='eq(n,213214)'&quot; -vframes 213213 h:\dh_framecorrect.mkv
  </code></pre>
  <p>again with no luck</p>
  <p>so what am doing wrong here, can anyone please help me out</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-08-18T04:07:13.313Z
Comments.Text: If the stream has B-frames, you may not be able to do it (without re-encoding) since the last displayed frame. may be a P-frame stored out-of-order i.e. not in last place.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-08-18T08:09:08.550Z
Comments.Text: I'm not sure why the file has this extra frame!! the original file I used has 213213 frames but the file I ended up with after it got encoded in an AI tool has this extra frame, that's why I need to remove this extra frame so I can inject the DoVI RPU file without getting that there is a mismatch in the number of frames error.
Comments.UserDisplayName: HSaber
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-08-19T14:07:34.603Z
Comments.Text: @Gyan Could you please shed some light on how can I achieve that
Comments.UserDisplayName: HSaber
Tags: <ffmpeg>
Title: How to delete the last frame without reencoding the file using ffmpeg
UserDisplayName: HSaber
ThreadText: # How to delete the last frame without reencoding the file using ffmpeg
  
  (Asked by: username_0 on 2024-08-18)
  
  I tried to use many variations of syntax but with no viable results.
  
  The frames in the original file are 213214 and I want to omit the last frame for the total frames to become 213213 but when I try the below syntax I get a very weird result which a higher number of frames rather being decreased by 1
  
  ```
  ffmpeg -copyts -i h:\dh.h265 -c copy -enc_time_base -1 -bsf:v:0 noise=drop='eq(pos\,213214)' h:\dh_framecorrect.mkv
  
  ```
  
  so I tried this syntax
  
  ```
  ffmpeg -i h:\dh.h265 -frames:v 213213 -c:v copy -c:a copy h:\dh_framecorrect.mkv
  
  ```
  
  but again with no luck
  
  then I tried another syntax like in below
  
  ```
  ffmpeg -copyts -i h:\dh.h265 -vf "select='eq(n,213214)'" -vframes 213213 h:\dh_framecorrect.mkv
  
  ```
  
  again with no luck
  
  so what am doing wrong here, can anyone please help me out
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: If the stream has B-frames, you may not be able to do it (without re-encoding) since the last displayed frame. may be a P-frame stored out-of-order i.e. not in last place.  
  > **username_0**: I'm not sure why the file has this extra frame!! the original file I used has 213213 frames but the file I ended up with after it got encoded in an AI tool has this extra frame, that's why I need to remove this extra frame so I can inject the DoVI RPU file without getting that there is a mismatch in the number of frames error.  
  > **username_0**: @username_1 Could you please shed some light on how can I achieve that  
  
  ---
  
  ## 0 answers
  
  