python-3.x 检查视频是否丢失帧的最快正确方法

azpvetkf  于 2022-12-14  发布在  Python
关注(0)|答案(1)|浏览(358)

我是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
qco9c6ql

qco9c6ql1#

它更像是def check_missing_frames(self)-〉可选[转储问题]:try:cmd = [“ffprobe”,“-打印格式”,“json”,“-显示条目”,“帧=编码图片编号”,字符串(自定义视频路径)

相关问题