Showing posts with label How to convert. Show all posts
Showing posts with label How to convert. Show all posts

Sunday, June 21, 2015

How to convert .avi/.wmv/.flv to .mp4 file through FFMPEG using VB.Net


There are lots of software and utilities available on the internet that can convert your video or audio files into the another formats like .avi, .wmv, .wav, .flv, .mov, .mp3, .aif, .3gp, etc...

Most of them are with paid features and if you could not pay then those softwares places some watermark on your vidoe files which looks awkward.

FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It contains libavcodec, libavutil, libavformat, libavfilter, libavdevice, libswscale and libswresample which can be used by applications. As well as ffmpeg, ffserver, ffplay and ffprobe which can be used by end users for transcoding, streaming and playing.

We can use FFMPEG in our code behind using vb.net or any other programming launguage and can make our life easy in order to processing video or audio files.

Below is a sample code for your reference that how we can call this ffmpeg.exe file in our code behind and process our required video or audio files.

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click   

    Dim strArgu As String, strNewFileName As String
       
    '--- Converting into MP4 file
        strArgu = " -i """ + Server.MapPath("<Source Directory>/" & <source file name>) + """ -s 480x320 -vcodec libx264 -acodec libfaac -ar 16000 -r 13 -ab 32000 -aspect 3:2 """ + Server.MapPath("<Target Directory>/" & <target file name.mp4>) + """"
   
    '--- Converting into MP3 file
    strArgu = " -i """ + Server.MapPath("<Source Directory>/" & <source file name>) + """ -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 """ + Server.MapPath("<Target directory>/" & <target file name.mp3>) + """"


        Dim proc As New Diagnostics.Process
        proc.StartInfo.Arguments = strArgu
        proc.StartInfo.FileName = Server.MapPath("ffmpeg.exe")
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.CreateNoWindow = True
        proc.StartInfo.RedirectStandardOutput = False

        Try
            proc.Start()
        proc.WaitForExit()
        Catch ex As Exception
            Throw ex
        End Try

End Sub
Click here to download FFMPEG file.