Open-Sora: Democratizing Efficient Video Production for All
Python
[fix] read_video for tools
zhengzangw2988d5be99be
diff --git a/opensora/datasets/read_video.py b/opensora/datasets/read_video.pyindex d344267..8cc4bca 100644--- a/opensora/datasets/read_video.py+++ b/opensora/datasets/read_video.py@@ -172,7 +172,7 @@ def read_video_cv2(video_path):return frames, vinfo-def read_video(video_path, backend='cv2'):+def read_video(video_path, backend='av'):if backend == 'cv2':vframes, vinfo = read_video_cv2(video_path)elif backend == 'av':diff --git a/tools/datasets/datautil.py b/tools/datasets/datautil.pyindex 6deba6a..3cbac44 100644--- a/tools/datasets/datautil.py+++ b/tools/datasets/datautil.py@@ -10,11 +10,12 @@ from glob import globimport cv2import numpy as npimport pandas as pd-import torchvisionfrom PIL import Imagefrom tqdm import tqdm+import torchvisionfrom .utils import IMG_EXTENSIONS+from opensora.datasets.read_video import read_videotqdm.pandas()@@ -116,7 +117,8 @@ def get_image_info(path, backend="pillow"):def get_video_info(path, backend="torchvision"):if backend == "torchvision":try:- vframes, _, infos = torchvision.io.read_video(filename=path, pts_unit="sec", output_format="TCHW")+ # vframes, infos = read_video(path)+ vframes, _, infos = torchvision.io.read_video(filename=path, pts_unit="sec", output_format="THWC")num_frames, height, width = vframes.shape[0], vframes.shape[2], vframes.shape[3]if "video_fps" in infos:fps = infos["video_fps"]