简体   繁体   中英

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);
        }

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.

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