<p>Use the tee muxer.</p>
<pre><code>ffmpeg -nostdin -hwaccel auto -fflags +igndts \
-f alsa \
  -ac 1 \
  -ar 44000 \
  -thread_queue_size 2048 \
  -i hw:2,1,0 \
-f video4linux2 \
  -thread_queue_size 2048 \
  -i /dev/video0 \
  -map 1 -map 0 \
  -vcodec libx264 \
  -preset ultrafast \
  -tune zerolatency \
  -s 1280x720 \
  -r 30 \
  -acodec aac \
  -t 00:00:05 \
-f tee &quot;[f=framehash]out/out.md5|[f=avi]out/out.avi&quot;
</code></pre>

CC BY-SA 4.0
2021-03-10T19:19:56.167Z
Thank you! This works! I am using `ffmpeg -hide_banner -fflags +genpts -i out/out.avi -c copy -f framehash out/out1.md5 ` to confirm the hashes. The hashes seem to line up, except the first and third frames are switched between the framehash files. The hashes keep the order throughout the rest of the file. Any ideas here? I updated the question with a screenshot comparing the two files.
Nova Trauben
CC BY-SA 4.0
2021-03-10T19:48:15.503Z
Check the stream #.
Gyan
CC BY-SA 4.0
2021-03-10T19:50:52.163Z
Stream 0 is video
Nova Trauben
CC BY-SA 4.0
2021-03-11T04:29:26.453Z
Yes, check the stream # on each line that you are comparing.
Gyan
CC BY-SA 4.0
2021-03-11T16:27:43.230Z
I checked again and for the 5 second avi formatted video there are some miss-matched frames. When I tried with mp4 everything matches. I posted two pastebins with the two avi framehash file. Any idea why this is happening with the avi format?
Nova Trauben
CC BY-SA 4.0
2021-03-10T04:02:04.883Z
2021-03-10T04:02:04.883Z
Gyan
<p>I am trying to use the ffmpeg framehash muxer to hash frames as they are being recorded.</p>
<p>I've tried</p>
<pre><code>ffmpeg -nostdin -hwaccel auto -fflags +igndts \
-f alsa \
  -ac 1 \
  -ar 44000 \
  -thread_queue_size 2048 \
  -i hw:2,1,0 \
  -acodec aac \
-f video4linux2 \
  -thread_queue_size 2048 \
  -i /dev/video0 \
  -vcodec libx264 \
  -preset ultrafast \
  -tune zerolatency \
  -s 1280x720 \
  -r 30 \
  -t 00:00:05 \
-f avi - \
| ffmpeg -nostdin -hwaccel auto \
-i - \
-f framehash out/out.md5 \
out/out.avi
</code></pre>
<p>The first ffmpeg command creates the streams (audio/video) and pipes to a second ffmpeg command in the avi format, which uses the framehash muxer then writes the avi file. The idea of using the piped command is that instead of the hashframe muxer using the rawvideo stream, it uses the encoded stream... That being said, hashframe seems to be using the rawvideo stream, and I can't get the mapping right.</p>
<p>I've tried <code>-map 1:0 -map 1:1 \</code> before the framehash, because I saw this with a channel of mpeg4 and mp3.</p>
<pre><code>Stream mapping:
  Stream #0:0 -&gt; #0:0 (h264 (native) -&gt; rawvideo (native))
  Stream #0:1 -&gt; #0:1 (mp3 (mp3float) -&gt; pcm_s16le (native))
  Stream #0:0 -&gt; #1:0 (h264 (native) -&gt; mpeg4 (native))
  Stream #0:1 -&gt; #1:1 (mp3 (mp3float) -&gt; mp3 (libmp3lame))
Output #0, framehash, to 'out/out.md5':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 1280x720, q=2-31, 331776 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.54.100 rawvideo
    Stream #0:1: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
    Metadata:
      encoder         : Lavc58.54.100 pcm_s16le
</code></pre>
<p>Anyways, when I compare the output files, (by running <code>ffmpeg -i out/out.avi -f framehash out/out1.md5</code> the hashes don't match. Any idea how I can fix this problem?</p>
<p>Thanks!!!
<a href="https://i.sstatic.net/DIqkK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/DIqkK.png" alt="framehash diffs" /></a>
<a href="https://pastebin.com/My3ppsTn" rel="nofollow noreferrer">Framehash output from stream</a></p>
<p><a href="https://pastebin.com/tvBMQWCb" rel="nofollow noreferrer">Framehash output from file</a></p>

<ffmpeg>
Using the ffmpeg hashframe muxer on encoded frames in real time
Nova Trauben
# Using the ffmpeg hashframe muxer on encoded frames in real time

(Asked by: username_0 on 2021-03-09)

I am trying to use the ffmpeg framehash muxer to hash frames as they are being recorded.
I've tried
ffmpeg -nostdin -hwaccel auto -fflags +igndts \
-f alsa \
  -ac 1 \
  -ar 44000 \
  -thread_queue_size 2048 \
  -i hw:2,1,0 \
  -acodec aac \
-f video4linux2 \
  -thread_queue_size 2048 \
  -i /dev/video0 \
  -vcodec libx264 \
  -preset ultrafast \
  -tune zerolatency \
  -s 1280x720 \
  -r 30 \
  -t 00:00:05 \
-f avi - \
| ffmpeg -nostdin -hwaccel auto \
-i - \
-f framehash out/out.md5 \
out/out.avi

The first ffmpeg command creates the streams (audio/video) and pipes to a second ffmpeg command in the avi format, which uses the framehash muxer then writes the avi file. The idea of using the piped command is that instead of the hashframe muxer using the rawvideo stream, it uses the encoded stream... That being said, hashframe seems to be using the rawvideo stream, and I can't get the mapping right.
I've tried -map 1:0 -map 1:1 \ before the framehash, because I saw this with a channel of mpeg4 and mp3.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> pcm_s16le (native))
  Stream #0:0 -> #1:0 (h264 (native) -> mpeg4 (native))
  Stream #0:1 -> #1:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Output #0, framehash, to 'out/out.md5':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 1280x720, q=2-31, 331776 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.54.100 rawvideo
    Stream #0:1: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
    Metadata:
      encoder         : Lavc58.54.100 pcm_s16le

Anyways, when I compare the output files, (by running ffmpeg -i out/out.avi -f framehash out/out1.md5 the hashes don't match. Any idea how I can fix this problem?
Thanks!!!

Framehash output from stream
Framehash output from file

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2021-03-10. Score: 0 | Accepted answer

Use the tee muxer.
ffmpeg -nostdin -hwaccel auto -fflags +igndts \
-f alsa \
  -ac 1 \
  -ar 44000 \
  -thread_queue_size 2048 \
  -i hw:2,1,0 \
-f video4linux2 \
  -thread_queue_size 2048 \
  -i /dev/video0 \
  -map 1 -map 0 \
  -vcodec libx264 \
  -preset ultrafast \
  -tune zerolatency \
  -s 1280x720 \
  -r 30 \
  -acodec aac \
  -t 00:00:05 \
-f tee "[f=framehash]out/out.md5|[f=avi]out/out.avi"

> **Comments:**
> **username_0**: Thank you! This works! I am using `ffmpeg -hide_banner -fflags +genpts -i out/out.avi -c copy -f framehash out/out1.md5 ` to confirm the hashes. The hashes seem to line up, except the first and third frames are switched between the framehash files. The hashes keep the order throughout the rest of the file. Any ideas here? I updated the question with a screenshot comparing the two files.  
> **username_1**: Check the stream #.  
> **username_0**: Stream 0 is video  
> **username_1**: Yes, check the stream # on each line that you are comparing.  
> **username_0**: I checked again and for the 5 second avi formatted video there are some miss-matched frames. When I tried with mp4 everything matches. I posted two pastebins with the two avi framehash file. Any idea why this is happening with the avi format?  

---

