How to convert video format files and capture multiple images from a video in .NET

Today I want to discuss an article in which this software application can be useful for many users i.e converting video formats and capture images from a video without actually downloading an MBs or GBs of software. Some users faces are with question marks or exclamatory marks thinking that is it really possible? For all those who put this exclamation or question marks in their faces my answer is yes for that. This is the article I want to discuss and share with all of you with snippet of code lines.

Now a days users are bothered of converting a video formats because one video format file may not compatible in all the players. Some video formats are compatible in windows media player and some video files are not compatible in the same player and some are compatible in xing player and some video files are not compatible in the same player. So you need to convert your video formats for playing in the Media player. So for that you really need a software in order to convert formats of those videos. But that's where the beauty of unix command comes to picture. You can easily convert any video format files and capture multiple images from video. This can be achieved with a simple and easily written of a unix command in your command prompt. This command will erase all the question and exclamation marks in your faces and convert different video formats,capture images from video. But for this you need an exe which is a free downloadable and it is less than 3 Mb of size. The exe name is ffmpeg. So how to use it. I will illustrate the usage of this and write snippets of code.

ffmpeg -i location of the input filename(with extension of the file) -ar 32000 -ab 64 and location of the destination file(with the extension of file) where you want to save it. ffmpeg will be in that specified drive. In the given Example C drive is the location of the ffmpeg.

c://ffmpeg -i c:/movie.avi -ar 32000 -ab 64 c:/movie.swf

Now i will briefly discuss above code snippet i had written here
ffmpeg: is the free exe downloadable from your search engine. This exe should be in that particular drive where you are typing your command in the command prompt.
-i : is the input that of the source file

Location of the Source Movie/Video:

The location of the source and destination movie file or video are any where in the computer. You just needs to specify the exact path

Audio rates and Audio bits:

This tells that how to increase/decrease the audio volumes of your video.You can increase the audio volume multiples of two i.e (ar and ab).And without this specification your videos can n't be converted in some versions of ffmpeg.

Location of the Destination Video:

can be any where and any drive in your computer that you want to save it after changing the video format.
You can also convert audio files with this.

And the second part is Converting of videos into images :

If you want to capture a particular frame of 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/....)and the extension of the image file maybe any type(.Png/.Jpeg/...).You just mention 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 above description (ie. converting video format files)but some discrepancy is to specify the frame rate you want to capture an image from the video that we have to mention here in this Command. Here in this above example 10 as frame rate with 1 sec duration and Width and height of the image is (550*450).

Still some people will go for a downloaded software to convert the video formats.But my article is intended to .Net programmers who wants to use a utility tool and call this ffmpeg exe from the .net code and hit this command in the Dos command prompt.

 proc = new Process()
proc.StartInfo.FileName = "your_app.exe"
proc.StartInfo.Arguments = ""
proc.StartInfo.UseShellExecute = false
proc.StartInfo.RedirectStandardInput = true
proc.StartInfo.RedirectStandardOutput = true

Thanks for reading the article .....

Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 74 articles authored by srirama


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: