sh.ff-fingerprinter
v1.3.0
Published
FF-FingerPrinter is a tool to create fingerprints of media files using their streams and properties thereof.
Downloads
8
Maintainers
Readme
FF-FingerPrinter
FF-FingerPrinter is a Node.js-based tool that uses ffmpeg
and ffprobe
to probe and fingerprint media files (anything that your ffmpeg can read). It supports hashing a media file's chapters and streams (currently video-, audio- and subtitle-streams are supported).
Install from npm
This package can be installed using the following command: npm install sh.ff-fingerprinter
.
This tool can be used as a library in your own project or as a standalone CLI
-application. JSDoc
-typedefs have been created to model the full output. The library exports the single class FFFingerPrinter
and some default configurations. The class makes extensive use of async
features.
The purpose is to uniquely identify media files and the streams they contain. This helps to identify duplicates and to avoid ID'ing files based on their names/paths or attributes or timestamps (which can easily be changed). Hashing of streams of a file can be done in parallel.
When hashing, the raw data of each stream is taken and put through a cryptographic hasher, such as sha256
(default). Also, properties of streams are hashed deterministically (sorted). Then, a hash for the whole file is computed and the file itself is analyzed using stat
. A remux of a file (containing the same streams as the original) will be ID'ed differently, but the streams' hashes will be identical (look below for an example output).
Command Line Interface (CLI)
Here is how to run FF-FingerPrinter from CLI:
In CLI-mode, a configuration file is used. An example can be found in cli/config.default.js
.
Example output
In CLI-mode, FF-Fingerprinter writes its result to stdout
while logging what it's doing to stderr
, so that you can pipe its JSON
-based output to a file.
Some noteworthy details:
- fingerprint: The hash of the entire file, taking into account all streams' and chapters' hashes. Replicates the value from
hashInfo.hashAll
. - hashWithProps: Is a hash over the streams' hash and its (deterministically) stringified properties.
numBytes
indicates how many bytes were read to create the hash. - The output of
ffprobe
is fully preserved and additional properties, such ashashInfo
andfffVersions
are added. Also, the settings (hashConf
) used for hashing are preserved, so that the results are repeatable.
Testing
Note that for testing, you need to have ffmpeg
and ffprobe
installed.