Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert video from Mp4 ,avi format to wmv format using C#

I have used Microsoft Expression Encoder to append two videos and this thing works Fine The problem is that when i tried to append videos other than 'wmv' ,it gives exception of FileNot Supported

I searched on google but i was unable to find the solution.

    private void button1_Click(object sender, EventArgs e)
    {

        MediaItem mediaItem1 = null;
        Job job = new Job();
        job.EncodeProgress += new EventHandler<EncodeProgressEventArgs>(job_EncodeProgress);
        int count = 0;
        //video url contains all urls of videos
        foreach (string x in VideosUrls)
        {
            if (count == 0)
            {
                mediaItem1 = new MediaItem(x);

                job.MediaItems.Add(mediaItem1);
            }
            else
            {
                mediaItem1.Sources.Add(new Source(x));
            }
            count++;
        }

        job.OutputDirectory = @"C://videoOutput";
        job.Encode();
    }

Is there any way using AForge.NET or Microsoft Expression Encoder so i can convert any 'mp4' video to 'wmv' programmatically before appending it with no Audio or quality Loss.

Thanks a lot for reading all Question :)

like image 809
Charlie Avatar asked Nov 11 '22 01:11

Charlie


1 Answers

I would check which edition of Windows Media encoder you have.

The "Express Edition" apparently, "does not support H.264 encoding".

The reality is you need a license for MP4 encoding from MPEG LA. Thats probably why only the paid versions of Expression Encoder support MPEG 4.

Logically, you can't convert from one video/audio format to another without loosing quality. WMV files typically contain video encoded in VC-1 and audio encoded in WMA. But a .mp4 file typically contains h.264 video and AC-3 audio.

So, your final .wmv file will need to contain only video in VC-1 which will mean decoding the h.264 video and encoding it in VC-1. That means quality loss.

VideoLan can tell you the codecs used inside your .mp4 and .wmv files. See this answer.

like image 84
Paul Avatar answered Nov 14 '22 22:11

Paul