mendevi.utils.compute_video_hash¶
- mendevi.utils.compute_video_hash(videos: str | bytes | Path | Iterable[str | bytes | Path], *, fast: bool = True) bytes | dict[Path, bytes][source]¶
Compute the checksum of the video.
For \(n\) hash of \(b\) bits, the proba of the colision \(C\) is \(p(C) = 1 - \left(\frac{2^k-1}{2^k}\right)^{\frac{n(n-1)}{2}}\).
The md5 hash uses \(b = 128\) bits. If we add one video per second durring 10 years, the proba of colision is about \(p(C) \approx 1.46*10^{-22}\).
That’s why the md5 hash is used to identify the video files.
Parameters¶
- videospathlike or list[pathlike]
The single or set of video you want to compute the signature.
- fastboolean, default=True
If the hash appears in the file name, it is returned immediately. If False, the actual checksum is systematically recalculated.
Returns¶
- signatures
The md5 checksum of the video file. In the case of a multiple file, a dictionary containing the file and the hash is returned rather a single hash. If the file does not exists, return None.