I've been searching for a tool that would take an image--a screenshot of a frame from a movie--and search every frame of one video from that same movie for that same image and give me either the frame number or a timestamp.

I've seen similar queries on this forum and there were ffmpeg command-lines that would do the job, but that hasn't worked out for me. Here is one command-line I've found there from 2016: Find Position in a Film/Video by a Frame

ffmpeg -i input.ts -loop 1 -i image.png -an -filter_complex "[0]crop=w:h:x:y[a];[1][a]blend=difference,blackframe=90:32" -f null - 

And this is the error message I got:

Input #0, mpegts, from 'input.ts':
  Duration: 02:04:46.06, start: 4200.000000, bitrate: 2037 kb/s
  Program 1
    Stream #0:0[0x1011](und): Video: h264 (High) (HDMV / 0x564D4448), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Input #1, png_pipe, from 'image.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24(pc), 953x398 [SAR 3779:3779 DAR 953:398], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264) -> crop
  Stream #1:0 (png) -> blend:top
  blackframe -> Stream #0:0 (wrapped_avframe)
Press [q] to stop, [?] for help
[Parsed_crop_0 @ 0000028b59bfac00] [Eval @ 0000009124dfe6d0] Undefined constant or missing '(' in 'w'
[Parsed_crop_0 @ 0000028b59bfac00] [Eval @ 0000009124dfe6d0] Undefined constant or missing '(' in 'h'
[Parsed_crop_0 @ 0000028b59bfac00] Error when evaluating the expression 'h'
[Parsed_crop_0 @ 0000028b59bfac00] Failed to configure input pad on Parsed_crop_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!

Here another ffmpeg code I got from [here in 2018][1]:

ffmpeg -i "input.ts" -r 1 -loop 1 -i image.png -an -filter_complex "blend=difference:shortest=1,blackframe=99:32" -f null - 2>&1 | grep blackframe | sed 's/.*frame\:\(.*\)/\1/'

And here's the error message:

'grep' is not recognized as an internal or external command,
operable program or batch file.

The version of ffmpeg I'm using is from December of 2020.

I also have Adobe's After Effects. Perhaps there's a plug-in of the tool I'm looking for.

  • What operating system are you on? It's strange that you don't have grep. Maybe you're on Windows or something else like that.
    – v010dya
    Commented Dec 26, 2021 at 7:36

1 Answer 1


The second ffmpeg command you posted works fine. The error message suggests that you are running the command on a non-unix-like system such as Windows. Just remove the part of the command after 2>&1 and it should work fine on windows. Here is the full command without unix/linux specific stuff: ffmpeg -i "input.ts" -r 1 -loop 1 -i image.png -an -filter_complex "blend=difference:shortest=1,blackframe=99:32" -f null -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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