How To Convert Movie File To FLV Format using ffmpeg

FFMpeg is a very popular open-source project consisting of vast libraries for handling audio and video related things.
In this article, I will show you how to convert video to flv format using C#. The code is self-explanatory; Here I am using C# Process API for invoking the FFmpeg executable and passing the required arguments.

public class FLVConvertor
{
	public void ConvertToFlv()
	{
		Process ffmpeg; // creating process
		string video;
		string mpg;
		video = Page.MapPath("FreeHugs.wmv"); // setting video input name with path
		mpg = Page.MapPath("") + "\\video.flv"; // thumb name with path !
		ffmpeg = new Process();
		ffmpeg.StartInfo.Arguments = " -i " + video + " -s 480*360 -deinterlace -ab 32 -r 15 -ar 22050 -ac 1 " + mpg; // arguments !
		ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe");

		ffmpeg.Start(); // start !
		ffmpeg.WaitForExit();
		ffmpeg.Close();

	}
	public void ExtractImage()
	{
		Process ffmpeg; // creating process
		string video;
		string thumb;
		video = Page.MapPath("video.flv"); // setting video input name with path
		thumb = Page.MapPath("") + "\\frame.jpg"; // thumb name with path !
		ffmpeg = new Process();
		ffmpeg.StartInfo.Arguments = " -i \"" + video + "\" -s 108*180 -vframes 1 -f image2 -vcodec mjpeg \"" + thumb + "\""; // arguments !
		ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe");
		ffmpeg.Start(); // start !

	}
}

Furthre Reading

Reactions

Post a Comment

6 Comments

  1. thank u very much its help a lot

    ReplyDelete
  2. You can also try Media Manager Pro for better performance and additional features

    http://www.all4dotnet.com/
    http://www.all4dotnet.com/

    ReplyDelete
  3. i have tried above code but it is exicuting only exe file but i want to store converted .flv file to flash folder.please can any one help me its very urgent
    thank you

    ReplyDelete
  4. protected void convert_Click(object sender, EventArgs e)
    {
    //converting video

    Process ffmpeg; // creating process
    string video;
    string mpg;

    video = Page.MapPath("VideoSource.avi");
    mpg = Page.MapPath("VideoTarget.flv");
    ffmpeg = new Process();


    ffmpeg.StartInfo.Arguments = " -i \"" + video + "\" -ar 44100 -ab 96 -f flv \"" + mpg + "\"";
    ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe");
    ffmpeg.Start(); // start !

    }

    ==================================
    you can read the manual ffmpeg at: http://forum.videohelp.com/threads/234825-FFMPEG-help

    ReplyDelete

Please do not post any spam link in the comment box😊

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)

Close Menu