FFMPEG – Video conversion

ffmpeg-%e2%80%93-video-conversion

FFMPEG – Video conversion & Thumbnail creation made easy

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It is a free software  licensed under the LGPL or GPL , consisting of command line tool to convert one video file format to another. It also supports grabbing and encoding in real time from a TV card. We can download the same using the url  http://www.ffmpeg.org/ .

Recently we have used this exe. to implement  video conversion, thumb nail creation and defining  the length of the video in an ASP.NET web site.

Now let us see steps involved in video conversion & thumbnail creation.

Video conversion :

Here we  use the ffmpeg.exe to convert different video formats into FLV format. We have used the System.Diagnostics.Process class to run the exe in asp.net. Next, input the command line arguments to the process in the below format.

Args = "-i \"" + inputfile + "\" -ar 22050 \"" + outputfile;

In the above code snippet, inputfile refers to the file to be converted and outputfile refers to the new name of the file with .flv extension. After executing the command with the ffmpeg.exe, it will send the output  as an FLV file to the given output folder.

Thumbnail creation:

Usually in websites, we display the video listings with thumbnails. Thumbnails are images which are extracted from the corresponding video frames. Here we  use the following command line argument to be passed to the ffmpeg.exe. The rest of the process is as similar to the above method.

args = "-i \"" + inputfile + "\" -vframes 1 -ss 00:00:07 -s 150×150 \"" + thumbname;

In the above code snippet, inputfile refers to the source file and thumbname refers to the destination thumbnail image to be created.

After executing the command with the ffmpeg.exe, it will place the output thumbnail image in the destination folder. We can choose any image format as output.
 
To define length of the video:

We can use the ffmpeg.exe to find the length of the video. Again we have to follow the same steps as we did for the above defined features.

args = "-i " + Videopath + "\"+ Video name;

After executing the command, we receive the output in "HH:MM:SS.UU" format. Here the ffmpeg process will return the result in Process.Standard Error. 

FFmpeg is a tool that, in its simplest form, implements a decoder and then an encoder, thus enabling the user to convert files from one container/codec combo to another. We  have implemented a scheduled processing of the conversion process asynchronously behind the curtain so that the normal users will get navigated as soon as they upload any video to the website. This is to avoid any performance bottle necks while executing these actions within a website as a single step process.

So for everyone who is curious about converting between video and audio formats ,rip ,shrink and refine a video using a single tool, FFmpeg  can serve as a contemporary and open source project which is also user friendly.

Related Posts

    No related posts found
This entry was posted in .NET, research and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>