General note: This question is also cross-posted on microsoft.public.win32.pro
grammer.di
rectx.vide
o and at the MSDN forums at
http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=3318206 -- if you're trying to solve this same issue in the future, check responses to the question in those places as well!
Hi guys,
I need some mechanism to append parts of a video into another file. Specifically, I'd like to do something like this:
1. "Recorder" program records some video to a temporary file. This application runs constantly, so the temporary file is always open for writing.
2. "Appending" program reads an arbitrary segment of this buffer file (say, from 5:00 to 10:00) and adds it to the end of the output file
3. Repeat until recorder program stops recording.
Specific details:
1. Both applications are run on Windows Server 2003. This rules out using Windows Media Foundation.
2. Because the recorder program runs constantly, our video container format must, MUST, MUST support seeking to an arbitrary place in the buffer file at the same time that the recorder program is writing to the buffer file.
After numerous searches on MSDN forums, newsgroups, and the web, I have not found any way to do this with the ASF format, since the video index is kept at the end of the file. Some developers have alluded to making their own source and sink filters, but that goes beyond the scope of our project budget.
In our initial tests, the only container format that allows us to do this is Matroska, which we can read and write using widely available DirectShow filters. We are using DivX as our compression codec. We are fairly committed to using Matroska since we have not found any other container format (ASF, AVI, or MPEG-TS) where DirectShow lets us play the file while another program is writing to it. However, we have some degree of flexibility on our choice of compression codec.
3. It is vital that we maintain video quality. We cannot afford to re-compress video from the buffer file to add it to the output file.
4. Ideally I would like some way to append to the output file "in-place". For example, the output file might be a gigabyte or more in size. If possible, I would like to avoid having to perform the disk I/O to copy this gigabyte-sized file to another file just to add on another 50 megabytes of video to the end.
I've spent the past few days researching API's to accomplish this. I ran across DirectShow Editing Services, which seems to support several editing options. However, I'm confused by the wording in this introduction topic:
<snip>
The core of DirectShow is a powerful architecture for handling streaming media. An application can use it to play multimedia content authored in a wide variety of formats, without the developer needing to worry about file compression and other tedious details. Prior to DES, however, DirectShow lacked the flexibility needed for nonlinear editing.
For example, suppose you wanted to create a video sequence consisting of 4 seconds from source A, followed by 10 seconds from source B, and ending with 5 seconds from source C. You could accomplish that much fairly easily using only the core DirectShow API.
</snip>
What core DirectShow API interfaces provide this functionality? I've searched for a variety of terms ("concatenate", "join" "append", "combine") and haven't found anything yet that doesn't require the ASF format.
Is DirectShow Editing Services my only option? Are there any other DirectShow-related APIs that I should use?
Thanks