Forums

Full Version: Merging Multiple Videos with DirectShow
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ideally, I'd like to be able to...

1) Concatenate multiple videos into a single video

2) Overlap the videos by a small amount (perhaps 0.5s) with a fade transition between the videos

3) Compress the resulting single video to MP4 format

Can I do this with your VideoLab library? I'm thinking I have to create a DSVideoPlayer instance for each source video, wire them each to a single VideoMixer component, add a DSVideoCompressor component, and then use a DSVideoLogger component to write out the resulting file.

Is this about right?

Dave

Sort of, compressing the video can be done by the logger already so you don't need the compressor component.

Regards,
Dave
Thanks, I'm really not clear how to implement the transition effects (0.5s fade between clips). Do I need to wire the ApplyAlpha component inline with each clip and programmatically change the alpha value at the right times for each clip?

Dave

There are multiple ways to accomplish this, try whichever suits your needs best. Using just the mixer might be enough though.

Regards,
Dave
So, I've got a collection of clips that I want concatenated one after the other in a single video file.

I've started writing the following code...

Code:
this.videoMixer.Channels.Clear();
            foreach (Clip clip in this.reel.Clips) {
                DSVideoPlayer dsVideoPlayer = new DSVideoPlayer();
                dsVideoPlayer.FileName = clip.FullFileName;

                VideoMixerChannelItem channelItem = new VideoMixerChannelItem();
                // Not sure how to connect the dsVideoPlayer to the VideoMixerChannelItem
                dsVideoPlayer.OutputPin = channelItem;  
                this.videoMixer.Channels.Add(channelItem);
            }

I'm assuming I need a DSVideoPlayer instance for each clip and it should be wired to a VideoMixerChannelItem but I'm not seeing how to connect the two. Guidance?

Dave

Can't test this at the moment but can you try something like: dsVideoPlayer.OutputPin.Connect(channelItem);

I assume there must be help-files included in the VC install as well, perhaps you can find some more info there too.

Regards,
Dave
I've not found any useful documentation. Not sure how to access any of the documention under c:\program files(x86)\LabPacks\DotNet\Help.

This is what I currently have...

Code:
private List<DSVideoPlayer> dsVideoPlayers = new List<DSVideoPlayer>();
        private int dsVideoPlayersIndex = 0;
        private void startButton_Click(object sender, EventArgs e) {
            this.videoMixer.Channels.Clear();
            this.dsVideoLogger.FileName = this.fileNameValueLabel.Text;
            
            this.videoMixer.Channels.Add(this.reel.Clips.Count);
            for (int i = 0; i < this.reel.Clips.Count; i++) {
                DSVideoPlayer dsVideoPlayer = new DSVideoPlayer();
                dsVideoPlayer.FileName = this.reel.Clips[i].FullFileName;
                dsVideoPlayer.Stopped += new EventHandler(dsVideoPlayer_Stopped);
                dsVideoPlayer.OutputPin.Connect(this.videoMixer.InputPins[i]);
                
                dsVideoPlayers.Add(dsVideoPlayer);
            }

            dsVideoPlayers[dsVideoPlayersIndex].Start();
        }

        void dsVideoPlayer_Stopped(object sender, EventArgs e) {
            this.dsVideoPlayers[this.dsVideoPlayersIndex].Stopped -= dsVideoPlayer_Stopped;
            this.dsVideoPlayersIndex++;
            if (this.dsVideoPlayersIndex < this.dsVideoPlayers.Count) {
                this.dsVideoPlayers[this.dsVideoPlayersIndex].Start();
            }
            else {
            }
        }

Is it correct that I should be starting each individual DSVideoPlayer at the right time to concatenate them properly?

Dave

Yeah, good idea..
mp3 Lame updated to 3.98.4 (3.98.3 had issues creating corrupted mp3 files at certain bitrates) Freeware wav to mp3 converter download directory: batch wav mp3 converter catch replace free download wav to mp3 record
Reference URL's