我是ffprobe的新手,你能建议有什么更快的方法来检查视频是否有丢失的帧吗?
def check_missing_frames(self) -> Optional[DumpIssue]:
try:
cmd = [
"ffprobe", "-print_format", "json",
"-show_entries", "frame=coded_picture_number", str(self._video_path)
]
output, _ = call_shell_cmd(cmd)
decoded = json.loads(output)
frames = [int(f["coded_picture_number"]) for f in decoded["frames"]]
except (ValueError, KeyError, TypeError, json.JSONDecodeError):
logging.exception("Couldn't check missing frames")
return FFProbeProcessingError()
# frames order not guaranteed
frames.sort()
for i in range(len(frames)-1):
if frames[i+1] - frames[i] != 1:
return VideoHasMissedFrames()
return None
1条答案
按热度按时间qco9c6ql1#
它更像是def check_missing_frames(self)-〉可选[转储问题]:try:cmd = [“ffprobe”,“-打印格式”,“json”,“-显示条目”,“帧=编码图片编号”,字符串(自定义视频路径)