Search code examples
c#asp.netms-media-foundation

Cut Video clip using Media foundation c#


I need to cut a part of video clip which is possible by ffmpeg but not want to use ffmpeg and want to strict with Media Foundation approach in asp.net. Can anyone suggest me how could be that possible. Requirement is that want to cut the live stream from end position to 4 minute back and then save in video file. We have to cut the video from live stream not for video saved already.


Solution

  • I can recommend you use ffmpeg or other video editor. Media Foundation is low level framework which is used for playing or encoding video. It does not include any functionality for cut of video clip. Of course, it is possible to write code for cut of video with Media Foundation, but it needs write all code from scratch. I have a rich experience with Media Foundation and I can compare it with 'LEGO' blocks - collection very 'tiny' elements. I think that it can take half year or more for implementing of your idea.

    By the way - you can find my source code for working with camera via Media Foundation Capturing Live-video from Web-camera on Windows 7 and Windows 8 and you can view complexity of code. It supports splitting video on two stream - viewing and other (for example recording). It is possible record video into the file via other stream, then after finishing of video recording create Media Foundation Media Session, open temp video file, set position video reader on for minutes from end, and rewrite into the destination file. However, you must understand Media Foundation very well. There is a book about Media Foundation. It includes code for Media Foundation Media Session.