简体   繁体   中英

Playing, editing then replaying a video in c# using directshow

As above, I'm looking to create a basic Windows.Forms GUI with two video players, one showing the original video and the other showing an edited version. Looking at using C#, but I'm open to using C/C++ if there's a particular reason to, it also doesn't have to be Windows.Forms but since it doesn't need to be particularly impressive visually I thought it would be the best due to simplicity/I have a little experience in it (although not for years).

At the moment I'm using AxWindowsMediaPlayer controls:

    private void loadMedia_btn_Click(object sender, EventArgs e)
    {         
        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        openFileDialog1.AddExtension = true;
        openFileDialog1.DefaultExt = "*.*";
        openFileDialog1.ShowDialog();

        initialVideoPlayer.URL = openFileDialog1.FileName;
        string fileName = openFileDialog1.FileName;
    }

Had a quick look at others such as DirectShow and OpenCV (mainly for the editing) but I'm not sure the best way to do it, since I can't seem to extract frames from the WMP control very easily, I didn't know if there was a neater way of doing it? One issue is that the computers in the labs don't seem to have DirectX (or at least not a new version) and so I'm not sure DirectShow will work.

I've looked at various questions like:

Take image from video playing on windows media player in C#

C# Windows Forms capture a image from embeded Windows Media Player

But they seem to create images which doesn't seem ideal since I'll be wanting to extract each frame in order to process them (applying interpolation, hopefully motion estimation, edge detection maybe).

So I'm looking to play the video, extract the frames and perform some processing, then putting everything back together to play in the 2nd player.

Thanks for any advice :)

You can use custom transform DirectShow filter to perform video processing or Sample Grabber filter with callback to perform processing directly in your code (can be slow in C#, but you can use Intel IPP invokes to make it very fast).

To edit video you can use simple graph with source, sample grabber and encoders/muxer or DirectShow Editing Services (if you are planning to provide more functionality in the future).

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