4

I am using FFmpeg to extract a screenshot through the timestamp, but I get this timestamp manually by watching the video in VLC and looking for the exact moment of the thumbnail was generated, this process is very time consuming and I need to do it with 220 videos.

All this in order to get a high resolution image of the thumbnail, I also have to mention that the thumbnail file does not have the timestamp in the metadata and in the title.

Would there be any way for FFmpeg to give me the exact timestamp where the thumbnail was taken?

UPDATED

After a couple of hours testing with FFmpeg commands I found the solution, it is not completely automatic but it works, then the command is:

ffmpeg -ss 00:02:30 -i video.mp4 -t 00:00:40 -loop 1 -i thumbnail.jpg \
   -filter_complex "scale=480:270,hue=s=0,blend=difference:shortest=1, \
    blackframe=95:30,fps=fps=23" -f null -

Options to modify:

  1. "video.mp4" replace for the video file (obviously).
  2. "thumbnail.jpg" replace for the thumbnail file.
  3. "-ss" and "-t" are the range of time where the thumbnail likely to be.
    • "-ss" time start 00:02:30 (2min with 30 sec)
    • "-t" time since start 00:00:40 (2min with 30sec + 40sec)
    • If you have no idea where probably is the thumbnail, you can delete this part, only it will take longer to find it.
  4. "480:270" replace for size of the thumbnail.
  5. "fps=23" change the 23 for the fps exact of the "video.mp4" file.

And answer we have:

[Parsed_blackframe_1] frame:3849 pblack:100 pts:160535 t:160.535000

In this example, we can see that the command has given us the exact timestamp where the thumbnail was generated "160.535000" which is in seconds with microseconds.

Now to extract the thumbnail in high resolution we could use the found timestamp, but consider that it would be more exact and precise to use the frame number, which in this case would be "frame:3849".

Using this command, we obtain the exact image:

ffmpeg -i video.mp4 -vf "select=gte(n\, 3849)" -vframes 1 high_resolution.png

Well I hope this is helpful for someone who is looking for the original image of a thumbnail or in general who needs to know exactly the minute where it was taken.

If someone in the future likes to make a script that can fully automate this process, I would be grateful :)

Community
  • 1
  • 1
joserick
  • 327
  • 3
  • 11

0 Answers0