locked
accurate AVI capture with AVI MUX RRS feed

  • Question

  • Hi:

     

    Someone might have asked this question before. However, I cannot seem to find an answer for it.

     

    I am trying to capture from a camera to an AVI file with AVI MUX connecting to FileWriter.

     

    I know the frame rate of the camera. My question is how to capture an accurate duration of AVI.

     

    I understand that it won't be accurate to use sleep in a  loop and do start/stop.

     

    Is there a way in the capture graph(AVI MUX) to specify the amount of frames after which it should stop the running of the graph?

     

    Thank you very much,

     

    cheers,

    Wednesday, October 29, 2008 6:48 PM

Answers

  • For a roughly ten second clip it is fairly easy.  It depends which language you are using.

     

    With a Windows application you can use

     

    Code Snippet

    ::SetTimer

     

    or

     

    CWnd::SetTimer if you are using MFC.

     

     

     

    Set the timer and when it is trigger, stop the graph.

     

    See the AmCap sample in the Windows SDK for an example of this technique.

     

    For exact frame accurate recording, you could implement a transform filter with a custom interface to specify the number of frames you want to capture and a windows message id to send to the application.  Then keep count of the frames that pass through the transform filter and return S_FALSE in the filter after the limit and send a message back to the application using

     

    Code Snippet

    ::PostMessage

     

     

     

    Wednesday, October 29, 2008 7:30 PM
  • No, I don't think you can put the filter between the AVI Mux and the File Writer.  You can look at the timestamps of the samples passing through your transform filter upstream of the AVI Mux to detect any dropped frames.

     

    Thursday, October 30, 2008 2:01 AM

All replies

  • For a roughly ten second clip it is fairly easy.  It depends which language you are using.

     

    With a Windows application you can use

     

    Code Snippet

    ::SetTimer

     

    or

     

    CWnd::SetTimer if you are using MFC.

     

     

     

    Set the timer and when it is trigger, stop the graph.

     

    See the AmCap sample in the Windows SDK for an example of this technique.

     

    For exact frame accurate recording, you could implement a transform filter with a custom interface to specify the number of frames you want to capture and a windows message id to send to the application.  Then keep count of the frames that pass through the transform filter and return S_FALSE in the filter after the limit and send a message back to the application using

     

    Code Snippet

    ::PostMessage

     

     

     

    Wednesday, October 29, 2008 7:30 PM
  • Thank you for your reply.

     

    I have tried the SetTimer method and it is always a little bit off.

     

    Your suggestion of transform filter sounds great. However, i am wondering if I can insert it between AVI MUX and the FileWriter. The reason is that there might be dropped frame and AVI MUX seems to be able to take care of the missing frame by adding an zero-length index entry.

     

    I want to count the dropped frame into the total duration of the capture. If I put the transform filter in front of the AVI MUX, I will have to implement the logic of detecting the dropped frame. I hope that by inserting the transform filter between AVI MUX and FileWriter, it will save me  some efforts.

     

    cheers,

     

     

     

    Wednesday, October 29, 2008 7:42 PM
  • No, I don't think you can put the filter between the AVI Mux and the File Writer.  You can look at the timestamps of the samples passing through your transform filter upstream of the AVI Mux to detect any dropped frames.

     

    Thursday, October 30, 2008 2:01 AM
  • Thank you very much for the help!!!

     

    cheers,

    Thursday, October 30, 2008 2:03 AM
  • You're welcome.

     

    After your question is answered please mark any helpful posts in the thread using the "Yes" button at the top of the posts to the right of  "Was this post helpful ?" in the heading.

     

    This helps people identify useful posts when using the search feature.

    Thursday, October 30, 2008 2:25 AM