Search code examples
c#winformswavmedia-playerwmv

Split wmv/wav file in WinForms application


I have a Windows Forms application, and I use an instance of Windows Media Player (via WMPLib) to play some audio/video files, either wmv or wav format. What I currently need to do is split the original file and "extract" one ore more clips from it, let's say 3-4 seconds from a specific point in time of the file.

Any ideas how to do this?

Third party libraries are ok, as long as they are not all that expensive


Solution

  • Have a look at the Windows Media Encoder SDK. Something like this:

    Int32 StartTime = 60 * 1000;
    Int32 EndTime = 120 * 1000;
    String SourceName = "original.mp3";
    String DestinationName = "split.mp3";
    WMEncBasicEdit SplitFile = new WMEncBasicEdit();
    SplitFile.MediaFile = SourceName;
    SplitFile.OutputFile = DestinationName;
    SplitFile.MarkIn = StartTime;
    SplitFile.MarkOut = EndTime;
    SplitFile.Start();
    

    should work.