Combine Two Video Files

Topics: Developer Forum, User Forum
Aug 18, 2009 at 8:31 PM

I have a website where users upload 10 second video files.  I would like to know if Splicer or DirectShow has built-in functions to allow me to take parts of each video to make an entirely new video?

Aug 20, 2009 at 7:43 PM

Yes, splicer is capable of doing it.

 

Asp.net with c# at the code behind and some simple splicer coding it will work.

 

You just create a time line, add each videofile to it and then encode it however you wish.

Coordinator
Aug 26, 2009 at 8:35 AM

Yep, no problem doing this.

Creating videos can be quite resource intensive though - it's often a good idea to give some thought to how you can do this without impacting on the user experience, and ensuring that you avoid creating the same video mashup repeatedly.  Exposing this as a restful service your website consumes can work quite well... as REST services lend themselves well to scaling out, and it naturally lends itself to giving the mashed up video resources meaingful urls.  And by changing content type you can view a mashups metadata (says as xml) vs. a flv or wmv.

I suggest taking a look at the unit tests to get a feel for what can be done - it's quite easy to do things like transitioning back and forth between one video and another on seperate tracks, with effects, or adding your own soundtrack to an existing set of video clips.  For anything a little more complicated you will need to dig into effects and transitions (there are quite a few commercialy available and public domain 3rd party efffects and transitions available for directshow as well).

Cheers,

 - Alex 

Sep 10, 2009 at 10:15 PM

Okay I have dug into Splicer with several tests conducted successfully.  However, I keep running into an issue where the webpage continuously runs without ever stopping.  It looks like the generated file is created on the server, but never finalized.  Have you run into this issue before?  I'm working with files less than 5MB, so it should be an issue of resource usage.  The code I'm using is below:

 

 

using (ITimeline timeline = new DefaultTimeline(25))
            {
                // greate our default audio track
                timeline.AddAudioGroup().AddTrack();
                // add a video group, 32bpp, 320x240 (32bpp required to allow for an alpha channel)
                IGroup videoGroup = timeline.AddVideoGroup(32, 320, 240);
                // add our default video track
                ITrack videoTrack = videoGroup.AddTrack();
                // add the video in "transitions.wmv" to the first video track, and the audio in "transitions.wmv"
                // to the first audio track.
                timeline.AddVideoWithAudio(fileInput);
                
                using (WindowsMediaRenderer renderer = new WindowsMediaRenderer(timeline, fileOutput, WindowsMediaProfiles.HighQualityVideo))
                {
                    renderer.Render();
                }
            }

 

 

	    using (ITimeline timeline = new DefaultTimeline(25))
            {
                // greate our default audio track
                timeline.AddAudioGroup().AddTrack();

                // add a video group, 32bpp, 320x240 (32bpp required to allow for an alpha channel)
                IGroup videoGroup = timeline.AddVideoGroup(32, 320, 240);

                // add our default video track
                ITrack videoTrack = videoGroup.AddTrack();

                // add the video in "transitions.wmv" to the first video track, and the audio in "transitions.wmv"
                // to the first audio track.
                timeline.AddVideoWithAudio(fileInput);
                
                using (WindowsMediaRenderer renderer = new WindowsMediaRenderer(timeline, fileOutput, WindowsMediaProfiles.HighQualityVideo))
                {
                    renderer.Render();
                }
            }