views:

157

answers:

0

how I can merge two or more wmv files using WMEncoder without lose quality. I'm using next code. but output file has very low quality(is unusable). Note: files were created with the same profile as for output.

public void Merge(ICollection<string> files, string output, string profileName)
    {
        WMEncoder Encoder = new WMEncoder();

        IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection;

        IWMEncProfile wmeProfile = FindProfile(profileName);
        int index = 1;
        int length = files.Count;
        foreach (var file in files)
        {
            // Add a source group to the collection
            IWMEncSourceGroup2 sourceGroup = (IWMEncSourceGroup2)SrcGrpColl.Add(string.Format("SG_{0}", index));
            sourceGroup.AutoSetFileSource(file);

            sourceGroup.set_Profile(wmeProfile);

            if (length > 1 && index < length)
            {
                sourceGroup.SetAutoRollover(-1, string.Format("SG_{0}", index + 1));
            }
            index++;
        }

        Encoder.File.LocalFileName = output;
        Encoder.PrepareToEncode(true);
        Encoder.Start();
    }