From ef1350bd3627afc515ed86a379ceea676ed5850a Mon Sep 17 00:00:00 2001 From: olegpokhilchenko <95915765+olegpokhilchenko@users.noreply.github.com> Date: Fri, 23 Jun 2023 18:38:16 +0300 Subject: [PATCH] Fix get_num_frames_in_video (#2090) * Fix get_num_frames_in_video * Make sure that there is a number * Fix output[0] --- nerfstudio/process_data/process_data_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nerfstudio/process_data/process_data_utils.py b/nerfstudio/process_data/process_data_utils.py index 459b90e70..5b7ae9686 100644 --- a/nerfstudio/process_data/process_data_utils.py +++ b/nerfstudio/process_data/process_data_utils.py @@ -17,6 +17,7 @@ import math import shutil import sys +import re from enum import Enum from pathlib import Path from typing import List, Literal, Optional, OrderedDict, Tuple, Union @@ -93,8 +94,9 @@ def get_num_frames_in_video(video: Path) -> int: -show_entries stream=nb_read_packets -of csv=p=0 "{video}"' output = run_command(cmd) assert output is not None - output = output.strip(" ,\t\n\r") - return int(output) + number_match = re.search(r"\d+", output) + assert number_match is not None + return int(number_match[0]) def convert_video_to_images(