You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug in the videoreader module. When I use the following two pieces of code to read image content, the results are different. The only difference between the two code snippets is whether the frame image is read within an if statement.Can you help me understand what the issue is? Which code is correct?
from decord import VideoReader, cpu
import os
from PIL import Image
save_dir = 'data/'
video_path = 'test.asf'
vr = VideoReader(video_path, ctx=cpu(0))
# 获取视频的总帧数和帧率
total_frames = len(vr)
fps = vr.get_avg_fps()
frames_to_save_per_second = 1
# 保存帧
saved_frame_count = 0
for i in range(total_frames):
# 判断是否需要保存当前帧
print(frames_to_save_per_second, fps, total_frames)
frame = vr[i].asnumpy()
img = Image.fromarray(frame)
if (i % int(fps // frames_to_save_per_second)) == 0:
# 计算时间戳
timestamp = i / fps
timestamp_str = f"{timestamp:.5f}" # 5位小数
file_path = os.path.join(save_dir, f"{timestamp_str}.jpg")
#log.debug(f"file_path: {file_path}")
img.save(file_path)
# timestamps_fact.append(timestamp_str)
saved_frame_count += 1
from decord import VideoReader, cpu
import os
from PIL import Image
save_dir = 'data/'
video_path = 'test.asf'
vr = VideoReader(video_path, ctx=cpu(0))
# 获取视频的总帧数和帧率
total_frames = len(vr)
fps = vr.get_avg_fps()
frames_to_save_per_second = 1
# 保存帧
saved_frame_count = 0
for i in range(total_frames):
# 判断是否需要保存当前帧
print(frames_to_save_per_second, fps, total_frames)
if (i % int(fps // frames_to_save_per_second)) == 0:
frame = vr[i].asnumpy()
img = Image.fromarray(frame)
# 计算时间戳
timestamp = i / fps
timestamp_str = f"{timestamp:.5f}" # 5位小数
file_path = os.path.join(save_dir, f"{timestamp_str}.jpg")
#log.debug(f"file_path: {file_path}")
img.save(file_path)
# timestamps_fact.append(timestamp_str)
saved_frame_count += 1
The text was updated successfully, but these errors were encountered:
There seems to be a bug in the videoreader module. When I use the following two pieces of code to read image content, the results are different. The only difference between the two code snippets is whether the frame image is read within an if statement.Can you help me understand what the issue is? Which code is correct?
The text was updated successfully, but these errors were encountered: