From 4564ade1fe5f149b763b9ddebc13fd774f560d6f Mon Sep 17 00:00:00 2001 From: Jackson Waschura <35237687+jackson-waschura@users.noreply.github.com> Date: Sat, 1 Apr 2023 16:29:33 -0700 Subject: [PATCH] Exposed number of actual frames to extract with ffmpeg for more transparency (#1683) * Exposed number of actual frames to extract for more transparency * Fixed off-by-one error in calculation of frames to extract. * Added math import * Switched print statements to CONSOLE.print --------- Co-authored-by: jackson-waschura --- nerfstudio/process_data/process_data_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nerfstudio/process_data/process_data_utils.py b/nerfstudio/process_data/process_data_utils.py index 817e2c6cd..a977df8b2 100644 --- a/nerfstudio/process_data/process_data_utils.py +++ b/nerfstudio/process_data/process_data_utils.py @@ -14,6 +14,7 @@ """Helper utils for processing data into the nerfstudio format.""" +import math import os import shutil import sys @@ -141,7 +142,7 @@ def convert_video_to_images( if num_frames == 0: CONSOLE.print(f"[bold red]Error: Video has no frames: {video_path}") sys.exit(1) - print("Number of frames in video:", num_frames) + CONSOLE.print("Number of frames in video:", num_frames) out_filename = image_dir / "frame_%05d.png" ffmpeg_cmd = f'ffmpeg -i "{video_path}"' @@ -157,6 +158,7 @@ def convert_video_to_images( spacing = num_frames // num_frames_target if spacing > 1: ffmpeg_cmd += f" -vf thumbnail={spacing},setpts=N/TB{crop_cmd} -r 1" + CONSOLE.print("Number of frames to extract:", math.ceil(num_frames / spacing)) else: CONSOLE.print("[bold red]Can't satisfy requested number of frames. Extracting all frames.") ffmpeg_cmd += " -pix_fmt bgr8"