norfair
norfair copied to clipboard
Skipped frames on avi videos
Describe the bug
Norfair seems to be skipping frames on .avi
videos
To Reproduce Using this 2 videos as examples: https://drive.google.com/file/d/10HPhUDNDbZ7tA9309-id8d2n4BX80gZb/view?usp=drive_link https://drive.google.com/file/d/1aJh1TjPRySPerdUsTo0A8tRnbKLU7ZBm/view?usp=drive_link
and this very simple script:
import argparse
from norfair import Video
from norfair.drawing.drawer import Drawer
def run():
parser = argparse.ArgumentParser(description="Track objects in a video.")
parser.add_argument("files", type=str, nargs="+", help="Video files to process")
args = parser.parse_args()
for path in args.files:
video = Video(input_path=path)
counter = 0
for frame in video:
frame = Drawer.text(frame, str(counter), (20,20))
counter += 1
video.write(frame)
if __name__ == "__main__":
run()
Play the output video on any player and you will see that the videos are no longer synchronized. Also notice that the loading bar when processing the video doesn't reach 100% on any video, this indicates that some frames are being skipped.
Expected behavior The videos should still be synchronized after processing.
Screenshots or videos
Environment (please complete the following information):
- OS: macos
- Python version: 3.8.18
- Norfair version: master
Additional context I transformed the videos to mp4 using ffmpeg and the problem is fixed