<p>I have been extracting frames from videos, editing these frames using ffmpeg, then converting the edited image sequence back into videos.</p>

<pre><code># Get the video's framerate
ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate video_in.webm
# e.g. cmd returns 5675/189

ffmpeg -i video_in.webm ./frames/image%05d.png
cd ./frames
# Image editing by various means, usually ending with
ffmpeg -i input1.png -i image%05d.png -filter_complex hstack ./output/image%05d.png
cd ./output
ffmpeg -framerate 5675/189 -i image%05d.png -c:v libvpx-vp9 -pix_fmt yuva420p -lossless 1 video_out.webm
</code></pre>

<p>For most videos, things work perfectly. For some, though, the output video seems to be missing the last few frames (e.g. maybe 0.5-1 seconds worth). In the latest video where it happened (though not the only one), I had deleted some of the ending frames of the original image sequence i.e. I extracted 220+ frames, manually deleted the last 20+, so I'm only left with ~200, performed additional editing as in the above code, then combined together back into a video. Yet when I view the video, it seems to stop at around frame 170-80+ and the rest is seemingly dropped.</p>

<p>I had seen it happen before, but those videos are maybe 1-2s long so I thought maybe it's too short, and settled for converting to gifs instead. But for this particular occurrence the output video is ~6s long. That's near the lower bound of the usual output video durations I work with.</p>

<p>Why is that happening? I'm not an expert in video-editing technicalities, so I don't know if I didn't configure something or is doing something wrong. What's going wrong here and how do I fix it? Thanks!</p>

CC BY-SA 4.0
2019-11-16T13:28:13.310Z
Check that there are no gaps in the numbering. The sequence filenames have to be a smooth unbroken series.
Gyan
CC BY-SA 4.0
2019-11-16T13:39:52.553Z
Yes, there're no gaps. The extracted images run from image00001 to image00227. After manual deletion I'm left with image00001 to image00206. When I convert to gif, all the frames are in the gif. But when I convert to video, the last ~0.5 seconds got cut off.
thegreatjedi
CC BY-SA 4.0
2019-11-16T14:02:47.787Z
How re you checking the video file?
Gyan
CC BY-SA 4.0
2019-11-16T14:03:31.343Z
I play the video in vlc player and the images from the last few frames (not the deleted ones) aren't inside
thegreatjedi
CC BY-SA 4.0
2019-11-16T14:10:01.617Z
Which frame of the input sequence does `ffmpeg -sseof -1 -i video_out.webm -update 1 lastfr.png` show?
Gyan
CC BY-SA 4.0
2019-11-16T14:23:56.653Z
hmm strange, it seems the last frame IS added in after all. It shows when I upload to gfycat, but not when I preview it via VLC player. Strange...well I guess it's not an issue anymore. Thanks for the help anyway!
thegreatjedi
<ffmpeg>
FFMPEG dropping last few frames when converting image sequence to video
thegreatjedi
# FFMPEG dropping last few frames when converting image sequence to video

(Asked by: username_0 on 2019-11-16)

I have been extracting frames from videos, editing these frames using ffmpeg, then converting the edited image sequence back into videos.
# Get the video's framerate
ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate video_in.webm
# e.g. cmd returns 5675/189

ffmpeg -i video_in.webm ./frames/image%05d.png
cd ./frames
# Image editing by various means, usually ending with
ffmpeg -i input1.png -i image%05d.png -filter_complex hstack ./output/image%05d.png
cd ./output
ffmpeg -framerate 5675/189 -i image%05d.png -c:v libvpx-vp9 -pix_fmt yuva420p -lossless 1 video_out.webm

For most videos, things work perfectly. For some, though, the output video seems to be missing the last few frames (e.g. maybe 0.5-1 seconds worth). In the latest video where it happened (though not the only one), I had deleted some of the ending frames of the original image sequence i.e. I extracted 220+ frames, manually deleted the last 20+, so I'm only left with ~200, performed additional editing as in the above code, then combined together back into a video. Yet when I view the video, it seems to stop at around frame 170-80+ and the rest is seemingly dropped.
I had seen it happen before, but those videos are maybe 1-2s long so I thought maybe it's too short, and settled for converting to gifs instead. But for this particular occurrence the output video is ~6s long. That's near the lower bound of the usual output video durations I work with.
Why is that happening? I'm not an expert in video-editing technicalities, so I don't know if I didn't configure something or is doing something wrong. What's going wrong here and how do I fix it? Thanks!

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Check that there are no gaps in the numbering. The sequence filenames have to be a smooth unbroken series.  
> **username_0**: Yes, there're no gaps. The extracted images run from image00001 to image00227. After manual deletion I'm left with image00001 to image00206. When I convert to gif, all the frames are in the gif. But when I convert to video, the last ~0.5 seconds got cut off.  
> **username_1**: How re you checking the video file?  
> **username_0**: I play the video in vlc player and the images from the last few frames (not the deleted ones) aren't inside  
> **username_1**: Which frame of the input sequence does `ffmpeg -sseof -1 -i video_out.webm -update 1 lastfr.png` show?  
> **username_0**: hmm strange, it seems the last frame IS added in after all. It shows when I upload to gfycat, but not when I preview it via VLC player. Strange...well I guess it's not an issue anymore. Thanks for the help anyway!  

---

## 0 answers

