Extract Thumbnails From a Video

My previous article explained how to convert a video file format into another video Format. This article explains how to extract thumbnails from a video. This is the article I want to explain and share with all of you with a snippet of code lines.

The Scenario is to extract a thumbnail from a video.

Before playing a video you must understand a little bit about the video that you are playing. For that you will place a thumbnail on top of the video. In some scenarios you want to extract thumbnails to show to the end user.

If you want to capture a specific frame of the video, a video is nothing but frames of images. So with ffmpeg we can capture multiple images from the video.

Note: The extension of the file name can be any type (avi, mpeg, swf or others) and the extension of the image file maybe any type (.png, .Jpeg or ohers). You just specify the exact extension of the video file.

ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg (or) ffmpeg -i yourfile.avi -an -ss 00:00:01 -t 00:01:31 -r 10 -s 550x450 -aspect 5:3 foo%3d.png

Similar to the preceding description (in other words converting video format files) but some discrepancy is to specify the frame rate you want to capture an image from the video that we need to specify here in this command argument. Here in this preceding example 10 as the frame rate with 1 second duration and a width and height of the image is (550*450).

  1. proc = new Process()  
  2. proc.StartInfo.FileName = "ffmpeg -i yourfile.avi -an -ss 00:00:01 -t 00:01:31 -r 10 -s 550x450 -aspect 5:3 foo%3d.png "  
  3. proc.StartInfo.Arguments = ""  
  4. proc.StartInfo.UseShellExecute = false  
  5. proc.StartInfo.RedirectStandardInput = true  
  6. proc.StartInfo.RedirectStandardOutput = true  
  7. proc.Start()  
  8. proc.WaitForExit()  
Still some people will use downloaded software to convert the video formats or to extract thumbnails from a video. But my article is intended to .Net programmers who want to use a utility tool and call this ffmpeg exe from the .Net code and hit this command argument in the command prompt.

The ffmpeg executable file will be like this. In your .Net project place this executable file in a specific folder, for example a Utility Folder.


Now let us watch how in the Command Prompt the command line argument works. The frame rate of each frame will be Increased.



Completion of extracting the thumbnails from the video command prompt looks as in this number of frames. Each frame is captured with an image is 910.



Now you are eager to see the thumbnails. So we will take a quick glance at that. Go to the D Drive where all the 910 thumbnails were placed in your drive.




 
Place/save all these thumbnails in your .Net project folder, say Images (depending on your requirements).
 
Now you want to see (open) one thumbnail, frame number 895.

Up Next
    Ebook Download
    View all
    Learn
    View all