Skip to content

Commit

Permalink
Allow framerate=0 to only capture first frame
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Jan 9, 2024
1 parent 23edf44 commit b3981c3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions processors/visualisation/video_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VideoFrames(BasicProcessor):
"type": UserInput.OPTION_TEXT,
"help": "Number of frames extracted per second to extract from video",
"tooltip": "The default value is 1 frame per second. For 1 frame per 5 seconds pass 0.2 (1/5). For 5 fps "
"pass 5, and so on.",
"pass 5, and so on. Use '0' to only capture the first frame of the video.",
"coerce_type": float,
"default": 1,
"min": 0,
Expand Down Expand Up @@ -108,13 +108,20 @@ def process(self):

command = [
shutil.which(self.config.get("video-downloader.ffmpeg_path")),
"-i", shlex.quote(str(path)),
"-r", str(frame_interval),
"-i", shlex.quote(str(path))
]

if frame_interval != 0:
command += ["-r", str(frame_interval)]
else:
command += ["-vframes", "1"]

if frame_size != 'no_modify':
command += ['-s', shlex.quote(frame_size)]
command += [shlex.quote(str(video_dir) + "/video_frame_%07d.jpeg")]

self.dataset.log(" ".join(command))

result = subprocess.run(command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Capture logs
Expand Down

0 comments on commit b3981c3

Please sign in to comment.