I write a video using cv2.VideoWriter with fps=5; VLC plays it back at 5fps; and ffprobe reports tbr=5.
I write it with fps=4.5; VLC plays it back at 4.5fps; but ffprobe reports tbr=9.
How can I detect 4.5 fps?
EDIT: BTW the metadata shown in windows file manager and using cv2 get(cv2.CAP_PROP_FPS) is 600fps.
EDIT2: Turns out the issue is only on Raspberry pi. Looks like cv2 does not write the metadata correctly as rpi/ffprobe works fine on a file created on laptop. However even the rpi created file plays fine so there must be a way VLC detects fps.
import cv2
source = "test.avi"
reader = cv2.VideoCapture(source)
writer = cv2.VideoWriter("temp.avi", cv2.VideoWriter_fourcc(*'DIVX'), 4.5, (800, 600))
while True:
res, img = reader.read()
if not res:
break
writer.write(img)
reader.release()
writer.release()