0

Newbie here. This is my input.mp4 video, according to VLC:

  • codec: H265 – MPEG-4 AVC (part 10) (avc1)
  • Encoder: Lavf58.29.100
  • FPS: 70.476432
  • Resolution: 1824 x 1216
  • Duration: 0m31s

I need to convert the video into a sequence of images. Is it possible to predict given the information above, how many frames I will get?

I tried two methods:

  1. Using OpenCV (basically with the command cv2.imwrite(name, frame, [cv2.IMWRITE_TIFF_COMPRESSION, 1]))
  2. Using ffmpeg (ffmpeg -i input.mp4 $filename%05d.tiff)

With OpenCV I get 2246 TIFF files (~14 GB). With ffmpeg I get more than 17k TIFF files but I had to stop the operation (see below) when it had already generated ~49GB of files.

You can tell that I am not an expert in this since initially I thought that my conversion should be 2185 TIFF files (from 2185 frames, i.e. FPS times Duration). But then I read another post and changed my expectation.

Anyway, is there a reliable way to know how many frames I should expect when exporting my video in a lossless file format?


Detail about ffmpeg: I had to stop the operation because it was taking forever and finding lots of duplicates (I don't know why, will make a separate post). Last lines shown in the operation were as follow:

More than 1000 frames duplicatedN/A time=00:00:01.04 bitrate=N/A dup=976 drop=0 speed=0.0308x                                                                                                
More than 10000 frames duplicated/A time=00:00:10.74 bitrate=N/A dup=9989 drop=0 speed=0.0265x                                                                                               
frame=17673 fps= 26 q=-0.0 Lsize=N/A time=00:00:17.67 bitrate=N/A dup=16428 drop=0 speed=0.0262x 

1 Answer 1

1

Your video looks to be variable frame rate, and its maximum frame rate looks to be fairly high. Which is what ffmpeg will use as target frame rate in constant frame rate mode for the output.

To keep 1:1 correspondence between input and output frames, add -fps_mode passthrough. For ffmpeg versions older than 5.1, add -vsync passthrough.

1
  • thanks a lot, it works! I also found some other ways to do it (see superuser.com/questions/1781258/…). However my original question remains, is there a reliable way to know how many frames I should expect when exporting my video in a lossless file format? I export to 2246 frames, and I have no idea where that number comes from.
    – terauser
    Apr 28, 2023 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.