Ravi
Ravi

Reputation: 307

concatenate video files DirectShow

Using C#,

How to concantenate two video files (.avi files) using DrirectShow ..? Kindly help!

Following code is just for explaining the issue ...

VideoSpanCollection newList = new VideoSpanCollection();
        int j;
        for(int i=0; i<oldItems.Count; i = j)
        {
            for(j=i+1;
                j<oldItems.Count && 
                oldItems[j].File.FullName == oldItems[j-1].File.FullName &&
                Math.Abs(oldItems[j].StartPosition - oldItems[j-1].StopPosition) < 0.5;
                j++);

            VideoSpan newSpan = new VideoSpan();
            newSpan.File = oldItems[i].File;
            newSpan.StartPosition = oldItems[i].StartPosition;
            newSpan.StopPosition = oldItems[j-1].StopPosition;
            AddSpanToListView(newSpan, -1);
        }

Upvotes: 1

Views: 2518

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69672

There is no standard/universal way to, not to mention that they have to be of compatible formats.

In DirectShow you need either custom filter that stream from 2+ sources and route data into recording leg of the pipeline, updating time stamps on the way.

DirectShow Editing Services (DES) might be of some help though it might re-compress the output while rendering the target file. Good news DES is also covered by DirectShow.NET and provides you with sample code to combine video and audio into single output file.

Samples\Editing\DESCombine
--------------------------
A class library that uses DirectShow Editing Services to combine video and audio 
files (or pieces of files) into a single output file.  A help file (DESCombine.chm) 
is provided for using the class.

Upvotes: 2

Related Questions