mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-11 18:44:21 +08:00
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 <jwaschur@calpoly.edu>
This commit is contained in:
1 parent
e104a3029e
commit
4564ade1fe
1 file changed
+3
-1
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user