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!

  • Check that there are no gaps in the numbering. The sequence filenames have to be a smooth unbroken series. – Gyan Nov 16 '19 at 13:28
  • 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 Nov 16 '19 at 13:39
  • How re you checking the video file? – Gyan Nov 16 '19 at 14:02
  • I play the video in vlc player and the images from the last few frames (not the deleted ones) aren't inside – thegreatjedi Nov 16 '19 at 14:03
  • Which frame of the input sequence does ffmpeg -sseof -1 -i video_out.webm -update 1 lastfr.png show? – Gyan Nov 16 '19 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.