none
DirectShow vs VFW realtime capture/record/playback, and the technology trend

    Question

  • I have searched about this issue extensively and there are not many descriptive answers elsewhere, I appreciate if you can help.

    First let me define my problem:
    I have some proprietary cameras that come with normal C libraries to control the camera settings and capture video frames (raw RGB bytes).
    I need to:
    1- Capture the video frames (in high frame rate such as 100fps) plus audio, and record them along with some synch information (an slider has a position t which is saved in a file along with frame number n). The slider position (t can be thought of as time) is changing faster than 100fps.
    2- Playback the video and audio. But with the restriction that frame number n must be played when slider is at position t (slider might go back and forth and usually is faster than 100fps)

    Note that no video editing is needed and a simple compression is more than fine for me to save some disk space.

    I have developed an application that captures the frames using camera drivers and writes them to an AVI file using VFW functions (AVIStreamXXX)
    For playback I again use AVIStreamXXX to read the frames and display them. The good point about this function is the simplicity and that I can play the video in a controlled fashion (by supplying the frame number to them).
    For audio I plan to use waveInXXX functions.

    My question are:
    1- Is DirectShow faster than VFW for recording? Note that for DS capture I may have to write my custom source filter to wrap around my camera library. How about playback? Is DS faster at playing back from AVI file?
    2- Is it possible to drive DS playback by supplying the frame number? I mean, can I take the slider output and feed it to DS to play a certain frame (instead of free running the video)? If the answer is yes, does this approach make DS considerably slower, nothing that it should wait for a frame number to play.
    3- One disadvantage of VFW over DS is the file size limit (2GB), what other disadvantages are there (or will be there in future)
    4- Is Media Foundation the new technology that is going to replace DS? I would like to ask you guys if you think Microsoft is going to REALLY make VFW (or sometime later DS) obsolete? By obsolete I mean that at some time it may not work at all.
    5- I have managed to implement everything without COM objects so far, and it seems DS programming needs a whole lot of COM interface coding, do you think it is worth it? I mean, from your perspective do you think DS is an overkill for a project like mine?
    6- Please let me know any suggestions and experience that you have had, thank you.

    dashesy
    Thursday, October 22, 2009 10:48 PM

Answers

  • 1.  DirectShow's speed advantage would be that it can used overlapped I/O for file writing.  Playback may also be faster given that it is going to by default render to a DirectDraw or Direct3D surface.  However DirectShow was not built with super high frame rates in mind.

    2.  No.  Every time you want to change the frame number you need to seek.  There is a fair amount of overhead in seeking with DirectShow.  To achieve this without seeking would require a custom AVI parser.

    3.  VFW is static, it's not likely to change for the better or worse.  DirectShow is also more or less frozen but at least the frame work is extensible to a certain degree.

    4.  MF is slowly replacing DS in MS's own software such as WMP and Movie Maker.  VFW has long been obsolete but they keep it alive for legacy support as there are still many apps using the interface, I would expect this to continue for some time.  DS has a greater feature set the MF for now, they have being updating MF with each OS release but not back releasing updates to older OS's.  So with MF you would find for instance that you have available a MPEG-4 video decoder on Windows 7 but not on Vista.

    5.  Given that you are doing things that don't really fit inside the DS standard behavior it may not be the best option.  The COM interface really isn't a negative though.

    6.  A fully custom app may be required to get the performance you desire.  I would ditch VFW altogether and write your own AVI reader that supports AVI 2.0, and write a renderer that uses Direct2D.  MF may also be an option but may still require a custom AVI reader for maximum performance in the way you want to use it.

    www.chrisnet.net
    • Marked as answer by dash esy Friday, October 23, 2009 4:11 PM
    Friday, October 23, 2009 2:13 PM

All replies

  • 1.  DirectShow's speed advantage would be that it can used overlapped I/O for file writing.  Playback may also be faster given that it is going to by default render to a DirectDraw or Direct3D surface.  However DirectShow was not built with super high frame rates in mind.

    2.  No.  Every time you want to change the frame number you need to seek.  There is a fair amount of overhead in seeking with DirectShow.  To achieve this without seeking would require a custom AVI parser.

    3.  VFW is static, it's not likely to change for the better or worse.  DirectShow is also more or less frozen but at least the frame work is extensible to a certain degree.

    4.  MF is slowly replacing DS in MS's own software such as WMP and Movie Maker.  VFW has long been obsolete but they keep it alive for legacy support as there are still many apps using the interface, I would expect this to continue for some time.  DS has a greater feature set the MF for now, they have being updating MF with each OS release but not back releasing updates to older OS's.  So with MF you would find for instance that you have available a MPEG-4 video decoder on Windows 7 but not on Vista.

    5.  Given that you are doing things that don't really fit inside the DS standard behavior it may not be the best option.  The COM interface really isn't a negative though.

    6.  A fully custom app may be required to get the performance you desire.  I would ditch VFW altogether and write your own AVI reader that supports AVI 2.0, and write a renderer that uses Direct2D.  MF may also be an option but may still require a custom AVI reader for maximum performance in the way you want to use it.

    www.chrisnet.net
    • Marked as answer by dash esy Friday, October 23, 2009 4:11 PM
    Friday, October 23, 2009 2:13 PM
  • Thank you that was very helpful.
    Friday, October 23, 2009 4:18 PM