Answers.Body: <p>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 <code>2&gt;&amp;1</code> and it should work fine on windows.
  Here is the full command without unix/linux specific stuff:
  <code>ffmpeg -i &quot;input.ts&quot; -r 1 -loop 1 -i image.png -an -filter_complex &quot;blend=difference:shortest=1,blackframe=99:32&quot; -f null -</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-13T17:45:02.627Z
Answers.LastActivityDate: 2023-03-13T17:45:02.627Z
Answers.UserDisplayName: user5864789
Body: <p>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.</p>
  <p>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:
  <a href="https://video.stackexchange.com/questions/19588/find-position-in-a-film-video-by-a-frame?newreg=eaed67a30ec24f4f8fcfe7fb7610b75a">Find Position in a Film/Video by a Frame</a></p>
  <pre><code>ffmpeg -i input.ts -loop 1 -i image.png -an -filter_complex &quot;[0]crop=w:h:x:y[a];[1][a]blend=difference,blackframe=90:32&quot; -f null - 
  </code></pre>
  <p>And this is the error message I got:</p>
  <pre><code>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) -&gt; crop
    Stream #1:0 (png) -&gt; blend:top
    blackframe -&gt; 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!
  </code></pre>
  <p>Here another ffmpeg code I got from [here in 2018][1]:</p>
  <pre><code>ffmpeg -i &quot;input.ts&quot; -r 1 -loop 1 -i image.png -an -filter_complex &quot;blend=difference:shortest=1,blackframe=99:32&quot; -f null - 2&gt;&amp;1 | grep blackframe | sed 's/.*frame\:\(.*\)/\1/'
  </code></pre>
  <p>And here's the error message:</p>
  <pre><code>'grep' is not recognized as an internal or external command,
  operable program or batch file.
  </code></pre>
  <p>The version of ffmpeg I'm using is from December of 2020.</p>
  <p>I also have Adobe's After Effects.  Perhaps there's a plug-in of the tool I'm looking for.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-26T07:36:54.490Z
Comments.Text: 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.
Comments.UserDisplayName: v010dya
Tags: <ffmpeg><video-editor>
Title: Tool for searching for a video's frame by an image file
UserDisplayName: Charles H.
ThreadText: # Tool for searching for a video's frame by an image file
  
  (Asked by: username_0 on 2021-06-02)
  
  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](https://video.stackexchange.com/questions/19588/find-position-in-a-film-video-by-a-frame?newreg=eaed67a30ec24f4f8fcfe7fb7610b75a)
  
  ```
  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.
  
  **Tags:** ffmpeg, video-editor
  
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-03-13. Score: 0
  
  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 -`
  
  
  ---
  
  