简体   繁体   中英

Encoding in MP4 using C# / DirectShow.Net / 3ivx

I wish to encode .wmv videos in MP4.

I use this little software available here : http://www.codeproject.com/Articles/11120/Media-files-conversion-using-C

I use DirectShow.Net : http://sourceforge.net/projects/directshownet/ and 3ivx codecs.

How can i change the code :

    //
    // This method convert the input file to an wmv file
    //
    void Convert2Wmv(string fileName)
    {
        try
        {
            label1.Text = "Encodage";
            button1.Enabled = false;

            hr = me.SetNotifyWindow(this.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);

            // here we use the asf writer to create wmv files
            WMAsfWriter asf_filter = new WMAsfWriter();
            IFileSinkFilter fs = (IFileSinkFilter)asf_filter;

            hr = fs.SetFileName(fileName + ".wmv", null);
            DsError.ThrowExceptionForHR(hr);

            hr = gb.AddFilter((IBaseFilter)asf_filter, "WM Asf Writer");
            DsError.ThrowExceptionForHR(hr);

            hr = gb.RenderFile(fileName + fExt, null);
            DsError.ThrowExceptionForHR(hr);

            hr = mc.Run();
            DsError.ThrowExceptionForHR(hr);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error converting to wmv: " + ex.Message);
        }
    }

To have MP4 encoding ? I'm a beginner in C#/ .Net ... =$

Thank you in advance. :3

You can use FFmpeg (a free command-line tool for Mac, Linux and Windows) to encode WMV to MP4. Here is an example syntax:

ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a libfaac -q:a 100 output.mp4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM