[FFmpeg-devel] [PATCH v2 3/3] avformat/hashenc: add streamhash muxer
Gyan
ffmpeg at gyani.pro
Wed Sep 11 17:27:43 EEST 2019
On 11-09-2019 07:04 PM, Moritz Barsnick wrote:
> Implemented as a variant of the hash muxer, reusing most functions,
> and making use of the previously introduced array of hashes.
> ---
> Changelog | 1 +
> doc/muxers.texi | 46 ++++++++++++++++++++++
> libavformat/Makefile | 1 +
> libavformat/allformats.c | 1 +
> libavformat/hashenc.c | 82 +++++++++++++++++++++++++++++++++++-----
> libavformat/version.h | 4 +-
> 6 files changed, 124 insertions(+), 11 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index 4b29e015a0..8eeed65680 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -9,6 +9,7 @@ version <next>:
> - Supoort AMD AMF encoder on Linux (via Vulkan)
> - IMM5 video decoder
> - ZeroMQ protocol
> +- streamhash muxer
>
>
> version 4.2:
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 20d31b279c..014f952d68 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -2064,6 +2064,52 @@ Specify whether to remove all fragments when finished. Default 0 (do not remove)
>
> @end table
>
> + at anchor{streamhash}
> + at section streamhash
> +
> +Per stream hash testing format.
> +
> +This muxer computes and prints a cryptographic hash of all the input frames,
> +on a per-stream basis. This can be used for equality checks without having
> +to do a complete binary comparison.
> +
> +By default audio frames are converted to signed 16-bit raw audio and
> +video frames to raw video before computing the hash, but the output
> +of explicit conversions to other codecs can also be used. Timestamps
> +are ignored. It uses the SHA-256 cryptographic hash function by default,
> +but supports several other algorithms.
> +
> +The output of the muxer consists of one line per stream of the form:
> + at var{streamindex}, at var{algo}=@var{hash}, where @var{streamindex} is the
> +index of the mapped stream, @var{algo} is a short string representing the
> +hash function used, and @var{hash} is a hexadecimal number representing the
> +computed hash.
> +
> + at table @option
> + at item hash @var{algorithm}
> +Use the cryptographic hash function specified by the string @var{algorithm}.
> +Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
> + at code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
> + at code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
> + at code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
> +
> + at end table
> +
> + at subsection Examples
> +
> +To compute the SHA-256 hash of the input converted to raw audio and
> +video, and store it in the file @file{out.sha256}:
> + at example
> +ffmpeg -i INPUT -f streamhash out.sha256
> + at end example
> +
> +To print an MD5 hash to stdout use the command:
> + at example
> +ffmpeg -i INPUT -f streamhash -hash md5 -
> + at end example
Since there's no mapping, this will select only one video and audio
stream, but more importantly the video will be first, which may not be
the case in the input. Maybe add mapping to the examples and/or add
stream type to the hash printout.
Gyan
More information about the ffmpeg-devel
mailing list