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!