0

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 diffs Framehash output from stream

Framehash output from file

0

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"
5
  • 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 Mar 10 at 19:19
  • Check the stream #. – Gyan Mar 10 at 19:48
  • Stream 0 is video – Nova Trauben Mar 10 at 19:50
  • Yes, check the stream # on each line that you are comparing. – Gyan Mar 11 at 4:29
  • 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 Mar 11 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.