Results 1 to 36 of 36

Thread: Save as Video File

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Save as Video File

    Ok I have a webcam runing and at the mo i have each individual image appearing in a picture box, is there any way to save this as a video file?

    Thanks, Pino

    Also, does anyone know haow to adjust setting such as contrast/darkness with a webcam? Are these done via the webcam or done to the actual picture?

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Save as Video File

    Quote Originally Posted by Pino
    Ok I have a webcam runing and at the mo i have each individual image appearing in a picture box, is there any way to save this as a video file?

    Thanks, Pino

    Also, does anyone know haow to adjust setting such as contrast/darkness with a webcam? Are these done via the webcam or done to the actual picture?

    If your trying to save it as a .avi file then this thread may help

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Thank-you i'll check that out

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok no it doesnt help me to well, since this is now api I will mover to api forum.

    Basicly, the constants RECORD etc i do not have values for... If it helps here is the code i am using for capture

    VB Code:
    1. Public Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    2. Public Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long
    3.  
    4. Public Const WM_CAP_CONNECT As Long = 1034
    5. Public Const WM_CAP_DISCONNECT As Long = 1035
    6. Public Const WM_CAP_GET_FRAME As Long = 1084
    7. Public Const WM_CAP_COPY As Long = 1054
    8.  
    9. Public Const WM_USER = &H400
    10. Public Const WM_CAP_START = WM_USER
    11. Public Const WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41
    12. Public Const WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42
    13. Public Const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43
    14. Public Const WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44
    15. Public Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45
    16. Public Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46
    17. Public Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
    18.  
    19.  
    20. Public mCap As Long
    21. Public irunning As Boolean
    22.  
    23. Public Function StartCamera() As Boolean
    24. irunning = True
    25.  
    26. On Error GoTo handler:
    27.  
    28.         mCap = capCreateCaptureWindow("WebCap", 0, 0, _
    29.                                     0, _
    30.                                     320, _
    31.                                     240, frmCamera.hwnd, 0)
    32.  
    33.         DoEvents
    34.    
    35.         SendMessage mCap, WM_CAP_CONNECT, 0, 0
    36.         SendMessage mCap, WM_CAP_SET_PREVIEW, 0, 0
    37.    
    38.         frmCamera.tmrCamera.Enabled = True
    39.         StartCamera = True
    40.        
    41. Exit Function
    42.  
    43. handler:
    44.     StartCamera = False
    45.     irunning = False
    46. End Function
    47.  
    48. Public Sub DisconnectCam()
    49. irunning = False
    50. DoEvents: SendMessage mCap, WM_CAP_DISCONNECT, 0, 0
    51. End Sub

    and my timer code...

    VB Code:
    1. SendMessage mCap, WM_CAP_GET_FRAME, 0, 0
    2.    
    3.     SendMessage mCap, WM_CAP_COPY, 0, 0
    4.    
    5.     CamShot.Picture = Clipboard.GetData

  5. #5
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Save as Video File

    Ah, I see - well you certainly cannot use that API without all the constants.

    Maybe this MSDN link will help:

    http://msdn.microsoft.com/library/de...eo_capture.asp

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Thanks for the help it is appriciated!,but thats in c++/c

    If anyone has the constants could they let me know?

  7. #7
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Save as Video File

    Quote Originally Posted by Pino
    Thanks for the help it is appriciated!,but thats in c++/c

    If anyone has the constants could they let me know?

    Maybe the author of the thread in the link I gave you can send them to you - he must have then to use his application

    Cheers and good luck,

    RyanJ
    My Blog.

    Ryan Jones.

  8. #8
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    You already have the constants:
    Code:
    Public Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45
    Public Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46
    Public Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50

  9. #9
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    And, I noticed you're sending the WM_CAP_SET_PREVIEW message, yet you're turning the preview off, rather than on. The wParam parameter should be "1" if you wish to turn previewing on. You might also want to look into the WM_CAP_SET_PREVIEWRATE which allows you to set the fps

    Also, why are you having your timer refresh the capture window, when you already have previewing on?

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    hey megatron thanks,

    I took an example off the net somwhere and this is how it showed it should be done, Could you point me in the right direction of how to do it properly? and if you get time explain each of the constants?

    Thanks!

  11. #11
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Save as Video File

    I found this example - does it help at all?

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  12. #12
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Save as Video File

    I don't know if this has any relevance, but here is code to do video capture in VB including saving to AVI format.
    http://www.shrinkwrapvb.com/vbvidcap.htm

  13. #13
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    Quote Originally Posted by Pino
    hey megatron thanks,

    I took an example off the net somwhere and this is how it showed it should be done, Could you point me in the right direction of how to do it properly? and if you get time explain each of the constants?

    Thanks!
    Well, looks like you're on track. Change the wParam parameter of WM_CAP_SET_PREVIEW to "1" to indicate you want to turn previewing on.

    Get rid of the code from your timer.

    Also call ShowWindow to make your window visible. Or alternatively, specify WS_VISIBLE as one of your window styles. Note: if you want the capture window to be drawn on the parent, specify the WS_CHILD style as well. Otherwise your window will be created as a top-level window (but still a child of frmCamera). E.g.
    VB Code:
    1. mCap = capCreateCaptureWindow("WebCap", WS_CHILD Or WS_VISIBLE, 0, _
    2.                                     0, _
    3.                                     320, _
    4.                                     240, frmCamera.hwnd, 0)

  14. #14
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    As for your constants, I'll try an explain them as best I can:

    WM_CAP_CONNECT
    Initializes your capture window (created with capCreateCaptureWindow) with the video capture driver

    WM_CAP_DISCONNECT
    Disconnects the video capture driver (Think Open/Close), and free's up any used resources

    WM_CAP_GET_FRAME
    Takes a single snapshot (1 frame) from the camera, and displays it in the capture window

    WM_CAP_COPY
    Copies a single frame to the clipboard (So like the above, except it goes to the clipboard, not the window)

    WM_USER
    Generic message to act as a starting point for control-specific messages so that they do not interfere with standard windows messages.

    WM_CAP_START
    Same as WM_USER (reference point)

    WM_CAP_DLG_VIDEOFORMAT
    WM_CAP_DLG_VIDEOSOURCE
    WM_CAP_DLG_VIDEODISPLAY
    WM_CAP_DLG_VIDEOCOMPRESSION
    The above 4 display various dialogs that allow the user to tweak with the video settings.

    WM_CAP_GET_VIDEOFORMAT
    WM_CAP_SET_VIDEOFORMAT
    Gets/sets the format of the captured video (surprise). These messages go hand-in-hand with WM_CAP_DLG_VIDEOFORMAT. Caveats when you use these, as not all drivers support all formats (i.e. compressed video).

    WM_CAP_SET_PREVIEW
    Enables or disables previewing. Previewing allows the captured video to be displayed in the capture window (as opposed to a file).

    MSDN should be able to provide a more in-depth answer, the above should get you started.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok I've ported this over to .NET since thats where I am going now, I have preview set up, can adjust frame rate, can take snapshots. I'm up to setting up recording but I cant find the values for these constants is there anywhere I can read up on this? I cant any resources of what to actually send with the contants, how to stop etc.

    Any Help appriciated!

  16. #16
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    To record, first send the WM_CAP_SET_SEQUENCE_SETUP message to the capture window, to toggle/set any options (time limit? fps? buffer settings? etc.) before you begin recording. This step isn't necessary but go through it to get a feel for the API.

    Next, send the WM_CAP_FILE_SET_CAPTURE_FILE message to tell VB which file to save the captured output to.

    Finally, send the WM_CAP_SEQUENCE to begin recording

    To stop recording, send the WM_CAP_STOP message.

  17. #17
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    Almost forgot, here are the constants for VB
    VB Code:
    1. Private Const WM_CAP_START As Long = WM_USER
    2. Private Const WM_CAP_STOP As Long = (WM_CAP_START+ 68)
    3. Private Const WM_CAP_SEQUENCE As Long = (WM_CAP_START+ 62)
    4. Private Const WM_CAP_SET_SEQUENCE_SETUP As Long = (WM_CAP_START+ 64)
    5. Private Const WM_CAP_FILE_SET_CAPTURE_FILEA As Long = (WM_CAP_START+ 20)

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok thanks,

    Let say I was using the WM_CAP_SET_SEQUENCE_SETUP constant how do i knwo what the wpram and LPram is supposed to represent? Is there any documentation on this?

  19. #19
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File


  20. #20

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok thanks megatron for all the help,

    I now have,

    VB Code:
    1. SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, "C:\myvideo1.avi", 0)
    2.         SendMessage(hHwnd, WM_CAP_SEQUENCE, 0, 0)

    Because i'm using vb.Net and the first parametr should be an integer, I'm getting a compile error on the line,

    SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, "C:\myvideo1.avi",0)

    Do you know any way around this? I cant CINT because its just not possible to convert that string. to an integer.

    Also because i cant tets it is my code correct? am i passing the correct parameters. I didnt have a clue what the, WM_CAP_SET_SEQUENCE_SETUP parameters were doing, well I did buts its In c code and i have no knowledge of c whatsoever.

    Pino

  21. #21
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    The filename is passed through lParam, not wParam.

    So try
    Code:
    SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, "C:\myvideo1.avi")

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Thanks megatron, only problem I am having is,

    1) WM_CAP_SET_SEQUENCE_SETUP - Could you explain what the params are?

    2) LPram is a Integer, and I am passing to it a string. Any because I am using .Net, I have option strict on. So I am getting a compiler Error.

    Thanks Again

    Pino

  23. #23

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok i;ve fixed the question 2)

    Ok its recording now but I cant do anything else while its recording? It locks out the program, and then if i click it stops recording. What are the ways around this? also here is my structure, is this right?

    VB Code:
    1. Private Structure CAPTUREPARMS
    2.         Dim dwRequestMicroSecPerFrame As String
    3.         Dim fMakeUserHitOKToCapture As Boolean
    4.         Dim wPercentDropForError As Integer
    5.         Dim fYield As Boolean
    6.         Dim dwIndexSize As String
    7.         Dim wChunkGranularity As Integer
    8.         Dim fUsingDOSMemory As Boolean
    9.         Dim wNumVideoRequested As Integer
    10.         Dim fCaptureAudio As Boolean
    11.         Dim wNumAudioRequested As Integer
    12.         Dim vKeyAbort As Integer
    13.         Dim fAbortLeftMouse As Boolean
    14.         Dim fAbortRightMouse As Boolean
    15.         Dim fLimitEnabled As Boolean
    16.         Dim wTimeLimit As Integer
    17.         Dim fMCIControl As Boolean
    18.         Dim fStepMCIDevice As Boolean
    19.         Dim dwMCIStartTime As String
    20.         Dim dwMCIStopTime As String
    21.         Dim fStepCaptureAt2x As Boolean
    22.         Dim wStepCaptureAverageFrames As Integer
    23.         Dim dwAudioBufferSize As String
    24.         Dim fDisableWriteCache As Boolean
    25.         Dim AVStreamMaster As Integer
    26.     End Structure

    and then I am passing this to the widnow in the setup procedure like so....

    VB Code:
    1. SendMessage2(hHwnd, WM_CAP_SET_SEQUENCE_SETUP, Len(Caprams), Caprams)

    Ignore the fact that it is sendmessage2 i had to create another instance of the api because i couldnt pass the structure through the last one becuas eit was declared as type string.

    Ok so can anyone help me? I wnat it to record in the background, and it will be recording 60 minute clips. I noticed the file size was huge as well 126 megs for a 19 second clip. Can you reduce this?

    Thanks

  24. #24
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    Here's a few I thought of, right off the bat:

    Have you tried lowering your preview rate? (fps)

    Have you disabled audio? Since it streams in at raw wave formats, it might take up a lot of space. Ensure fCaptureAudio = 0 for CAPTUREPARAMS

    Also try changing the formatting via the WM_CAP_SET_VIDEOFORMAT message. You can specify the resolution and colour depth, which is passed through a familiar BITMAPINFO structure. This structure contains another BITMAPINFOHEADER where you set these properties.

    I.e.
    VB Code:
    1. Dim bmi As BITMAPINFO
    2. With bmi.bmiHeader
    3.     .biSize = Len(bmi.bmiHeader)
    4.     .biPlanes = 1
    5.     '256 colours and small resolution of 160x240
    6.     .biBitCount = 8
    7.     .biWidth = 240
    8.     .biHeight = 160
    9. End With
    10.  
    11. If SendMessage2(hHwnd, WM_CAP_SET_VIDEOFORMAT, Len(bmi), bmi) = 0 Then
    12.     MsgBox "Invalid format"
    13. End if
    Set the format after you're connected to a driver, but before you begin recording.

  25. #25

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    Ok thanks for the info, what abou the fact it will not run in the backround? can that be fixed? When i hit record it freezes out the rest of the app.

    Pino

  26. #26
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286

    Re: Save as Video File

    Set the fYeild member of the CAPTUREPARMS structure to 1. This will run the capture window in separate thread.

  27. #27

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    It didnt make a differance,

    VB Code:
    1. Caprams.fYield = True
    2.  
    3.         SendMessage2(hHwnd, WM_CAP_SET_SEQUENCE_SETUP, Len(Caprams), Caprams)
    4.         SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, FullFile)
    5.         SendMessage(hHwnd, WM_CAP_SEQUENCE, 0, CType(0, String))

    I've read that on the msdn but when i try it it doenst seme to make a differance, with or without it.

    Pino

  28. #28
    Junior Member
    Join Date
    Mar 2005
    Posts
    23

    Re: Save as Video File

    This is how I changed the CapParams structure and then with the .fYield = False
    will enable multi threading and then you applicatio wont freeze.
    .fLimitEnabled = True
    .wTimeLimit = 3
    with the above 2 options you can stop the recording after a specified time.
    My app works fine with this i am able to run 2 cameras now.

    With CapParams
    ' // set the defaults we won't bother the user with
    ' show message after pre-roll
    ' .fMakeUserHitOKToCapture = -(True) ' - converts VB Boolean to C BOOL
    ' in case we use error callbacks later
    .wPercentDropForError = 10
    ' fUsingDOSMemory is obsolete
    .fUsingDOSMemory = False
    ' The number of video buffers should be enough to get through
    ' disk seeks and thermal recalibrations
    .wNumVideoRequested = 32
    ' Do abort on the left mouse
    '.fAbortLeftMouse = -(True)
    ' Do abort on the right mouse
    '.fAbortRightMouse = -(True) '- converts VB boolean to C BOOL
    ' If wChunkGranularity is zero, the granularity will be set to the
    ' disk sector size.
    .wChunkGranularity = 0
    ' use default
    .dwAudioBufferSize = 0
    ' attempt to disable caching
    .fDisableWriteCache = -(True)
    ' not using MCI
    .fMCIControl = False
    .fStepCaptureAt2x = False
    ' not multi-threading
    .fYield = False
    ' request audio buffers
    .wNumAudioRequested = 4 '10 is max limit


    ' //these parameters are loaded from registry
    ' If "AUDIO" = Trim$(UCase(GetSetting(App.Title, "preferences", "streammaster", "AUDIO"))) Then
    ' .AVStreamMaster = AVSTREAMMASTER_AUDIO 'use audio clock to synchronize AVI
    ' Else
    .AVStreamMaster = AVSTREAMMASTER_NONE
    ' End If
    'set index size of AVI file (max frames)
    .dwIndexSize = Val(GetSetting(App.Title, "preferences", "maxframes", INDEX_15_MINUTES))

    .fYield = True
    ' //Now set the parameters from the UserInput
    ' .dwRequestMicroSecPerFrame = microsSecFromFPS(Val(txtFps.Text))
    .dwRequestMicroSecPerFrame = microsSecFromFPS(15)
    .fCaptureAudio = False '-(CBool(chkAudio.Value))
    .fLimitEnabled = True ' -(CBool(chkLimit.Value))
    .wTimeLimit = 3 ' Val(txtSec.Text)

    End With


    Call capCaptureSetSetup(frmMain.capwnd, CapParams)

  29. #29
    New Member
    Join Date
    Apr 2007
    Posts
    1

    Re: Save as Video File

    Hi,

    @Pino: (i know, this thread ist really old )

    Can you tell me how you solved this Problem?
    2) LPram is a Integer, and I am passing to it a string. Any because I am using .Net, I have option strict on. So I am getting a compiler Error.
    Do i have to declare another sendmessage with different params?

    i have search the whole weekend but i didnt find any solution that worked for me.

    Greetz

    Pendler

  30. #30
    New Member
    Join Date
    May 2007
    Posts
    1

    Re: Save as Video File

    This thread had a very help to my project, but i have another questions:

    SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, "C:\myvideo1.avi") - this command don´t save a video file with name "myvideo1.avi", the file created is capture.avi.
    I need see the cam while video file is created, is it possible?

    Sorry about my bad english...

  31. #31
    New Member
    Join Date
    Dec 2007
    Posts
    2

    Re: Save as Video File

    An old thread, but you can't imagine how useful it was for me!! THANKS TO ALL OF YOU!
    Just a note:
    After several days and lots of madness, I was one of those who couldn't make it save to the file I specified. BUT NOW I CAN! Just in case someone happens to be in the same situation:
    1)In the beginning of my module, it reads
    Code:
    Option Explicit On
    Option Strict On
    Imports System.Runtime.InteropServices
    2)SendMessage definition:
    Code:
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
           (ByVal hwnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, _
           <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
    3)Finally:
    Code:
    Public Function OpenPreviewWindow(ByVal TargetPictureBox As PictureBox) As Boolean
            ' Open Preview window in picturebox
            hWnd = capCreateCaptureWindowA("CamCap", WS_VISIBLE Or WS_CHILD, 0, 0, 320, 240, TargetPictureBox.Handle.ToInt32, 0)
    
            ' Connect to device
            If (SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, DeviceID, 0) <> 0) Then
                'Set the preview scale
                SendMessage(hWnd, WM_CAP_SET_SCALE, 1, 0)
    
                'Set the preview rate in milliseconds
                SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
    
                'Start previewing the image from the camera
                SendMessage(hWnd, WM_CAP_SET_PREVIEW, 1, 0)
    
                ' Resize window to fit in picturebox
                SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, TargetPictureBox.Width, TargetPictureBox.Height, SWP_NOMOVE Or SWP_NOZORDER)
    
                Return True
            Else
                ' Error connecting to device. close window
                DestroyWindow(hWnd)
                Return False
            End If
        End Function
    
        Public Sub StartRecording()
            Dim FileName As String
            FileName = Application.StartupPath & "\" & Application.ProductName & ".avi"
            SendMessage(hWnd, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, FileName)
    
            SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0)
        End Sub
    
        Public Sub ClosePreviewWindow(ByVal RecordingVideo As Boolean)
            ' Stop capture
            SendMessage(hWnd, WM_CAP_STOP, 0, 0)
    
            ' Disconnect from device
            SendMessage(hWnd, WM_CAP_DRIVER_DISCONNECT, DeviceID, 0)
    
            ' Close window
            DestroyWindow(Hwnd)
        End Sub
    I hope this is useful for someone!

  32. #32
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Save as Video File

    Welcome to the forums.

    Thanks for sharing your code.

  33. #33

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Save as Video File

    I'll take a look at this as its somthing I dropped and never came back to.

    Thanks

  34. #34
    New Member
    Join Date
    Dec 2007
    Posts
    2

    Re: Save as Video File

    Cheers Pino!
    Where did you leave it? Does it still froze when you record video?
    I have managed to fyeild it, but still my video quality is not superb, and haven't tried yet to compress it (compressing using DivX or wathever WITHOUT dialog boxes would be just great!)

  35. #35
    Junior Member
    Join Date
    Aug 2006
    Location
    Montreal, Quebec
    Posts
    27

    Resolved Re: Save as Video File

    [BUMP]

    Bumping this thread in the hope someone will be able to help out!
    i'm using this structure followed by the relevent sub (all variable and API are declared properly)

    Code:
     
    Public Structure CAPTUREPARMS
            Dim dwRequestMicroSecPerFrame As Long
            Dim fMakeUserHitOKToCapture As Long
            Dim wPercentDropForError As Long
            Dim fYield As Long
            Dim dwIndexSize As Long
            Dim wChunkGranularity As Long
            Dim fUsingDOSMemory As Long
            Dim wNumVideoRequested As Long
            Dim fCaptureAudio As Long
            Dim wNumAudioRequested As Long
            Dim vKeyAbort As Long
            Dim fAbortLeftMouse As Boolean
            Dim fAbortRightMouse As Boolean
            Dim fLimitEnabled As Long
            Dim wTimeLimit As Long
            Dim fMCIControl As Long
            Dim fStepMCIDevice As Long
            Dim dwMCIStartTime As Long
            Dim dwMCIStopTime As Long
            Dim fStepCaptureAt2x As Long
            Dim wStepCaptureAverageFrames As Long
            Dim dwAudioBufferSize As Long
            Dim fDisableWriteCache As Long
            Dim AVStreamMaster As Long
        End Structure
    
    Public Sub StartRecording(ByVal tgt As PictureBox)
            Dim MyParams As CAPTUREPARMS
    
            With MyParams
                .fAbortLeftMouse = 0
                .fAbortRightMouse = 0
                .fCaptureAudio = 0
                .fYield = 0
                
            End With
            hWnd = capCreateCaptureWindowA(0, WS_VISIBLE Or WS_CHILD, 0, 0, 0, 0, tgt.Handle.ToInt32, 0)
            Dim a As Boolean
            a = SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0)
            a = SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
            a = SendMessage(hWnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
            a = SendMessage(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, "C:\myvideo1.avi")
            a = SendMessage(hWnd, WM_CAP_SET_SEQUENCE_SETUP, 96, MyParams)
            a = SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0)
    
        End Sub
    The probleme is that if I REM the line
    Code:
    SendMessage(hWnd, WM_CAP_SET_SEQUENCE_SETUP, 96, MyParams)
    the file is save fine and can be played back no problem, but if I dont REM it , it creates an empty file that cannot be played back

    also the command Len(MyParams) returns a value of 192 but if I use a value above 96 the command line returns "False" 192/2 = 96...?? unicode character?

    can anyone see what i'm doing wrong?

    Thanks
    Stormer

  36. #36
    Junior Member
    Join Date
    Aug 2006
    Location
    Montreal, Quebec
    Posts
    27

    Re: Save as Video File

    Found my own answer

    Code:
    With MyParams
                .dwRequestMicroSecPerFrame = 66667
                .fMakeUserHitOKToCapture = 0
                .wPercentDropForError = 10
                .fYield = 1
                .dwIndexSize = 324000
                .wChunkGranularity = 0
                .wNumAudioRequested = 10
                .wNumVideoRequested = 10
                .fCaptureAudio = 0
                .dwAudioBufferSize = 10
                .fAbortLeftMouse = 0
                .fAbortRightMouse = 0
                .fStepCaptureAt2x = 0
                .fLimitEnabled = 0
                .wTimeLimit = 0
                .fMCIControl = 0
                .wStepCaptureAverageFrames = 5
                .dwAudioBufferSize = 10
    
    
            End With
    seems you have to fill most fields for this to work! i used the above definition and it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width