[Gambas-user] Did anyone have a script to record webcame picture in video files

firman firman.isb at ...626...
Sat Dec 18 01:11:30 CET 2010



I Almost done my project about monitoring camera using webcam with gambas
3... the picture or streaming video can displayed on picturebox but i still
have a problem to record in video file mode r like avi,  mpg or other
compressed format.. please help me if anyone can solve my problem. i will
showing u a picture of FMain my project... the record button still couldn't
worked...

i'm using gambas 3 svn... I've wrote the script like this, and worked the
files created but still 0 KB or nothing recorded....
this is the script:

'Proses Menyimpan File record

Public Sub InitCapture()
 
  If Not CatProcess Then
    bytesrecorded = 0
    CatProcess = Exec ["cat", "/dev/video0"] For Read
    CatProcess = Exec ["cat", "/dev/video1"] For Read
    CatProcess = Exec ["cat", "/dev/video2"] For Read
    CatProcess = Exec ["cat", "/dev/video3"] For Read
     
  Endif
 
  UpdateBytesLabel()
 
End

Public Sub Process_Write(data As String)

 If pic1.Picture = $cam1.Image.Picture Then
   If pic2.Picture = $cam2.Image.Picture Then
     If pic3.Picture = $cam3.Image.Picture Then
       If pic4.Picture = $cam4.Image.Picture Then
       Return 
       Endif
     Endif
   Endif
  Endif
 
  Try pic1.Picture.send(data)
  Try pic2.Picture.send(data)
  Try pic3.Picture.send(data)
  Try pic4.Picture.send(data)
  Try saveprocess.send(data)
 
  bytesrecorded = bytesrecorded + Len(data)
 
End


Public Sub btnRecord_Click()
 
 If btnRecord.text = "Record" Then
    bytesrecorded = 0
    starttime = Now
    endtime = starttime
    initcapture()
    Tmr1_Timer()
    btnRecord.text = "Stop"
    SaveProcess = Exec ["bash", "-c", "cat > " & setFilename1()] For Write
    SaveProcess = Exec ["bash", "-c", "cat > " & setFilename2()] For Write
    SaveProcess = Exec ["bash", "-c", "cat > " & setFilename3()] For Write
    SaveProcess = Exec ["bash", "-c", "cat > " & setFilename4()] For Write
  Else
    endtime = Now
   
    Try saveprocess.kill
    btnRecord.text = "Record"
    setFilename1()
    setFilename2()
    setFilename3()
    setFilename4()
  Endif
End

Public Function setFilename1() As String
 
  Dim i As Integer

  i = 0
  'Do While Exist(Application.Path &/ "kamera1" & i & ".mpg")
  Do While Exist(User.Home &/ "kamera1" & i & ".mpg")
  i = i + 1
  Loop
  'Return Application.Path &/ "kamera1" & Format(i, "000") & ".mpg"
  Return User.Home &/ "kamera1" & Format(i, "000") & ".mpg"
 
End


Public Function setFilename2() As String
 
  Dim i As Integer
  i = 0
  Do While Exist(User.Home &/ "kamera2" & i & ".mpg")
    i = i + 1
  Loop
  Return User.Home &/ "kamera2" & Format(i, "000") & ".mpg"
 
End


Public Function setFilename3() As String
 
  Dim i As Integer
  i = 0
  Do While Exist(User.Home &/ "kamera3" & i & ".mpg")
    i = i + 1
  Loop
  Return User.Home &/ "kamera3" & Format(i, "000") & ".mpg"
 
End


Public Function setFilename4() As String
 
  Dim i As Integer
  i = 0
  Do While Exist(User.Home &/ "kamera4" & i & ".mpg")
    i = i + 1
  Loop
  Return User.Home &/ "kamera4" & Format(i, "000") & ".mpg"
 
End

Public Sub UpdateBytesLabel()
  Dim i As Float
  If bytesrecorded > 1048576 Then
    i = Int(bytesrecorded / 100000)
  Else
    i = Int(bytesrecorded / 100)
  Endif
 
End

Public Sub UpdateTimeLabel()
 
  If starttime = "00:00:00" Then Return
  If endtime <> starttime Then Return
 
  TextDate1.text = Time(CDate(CInt(Now) + (Now - starttime) +
timezoneadjust))
 
End

anyone can solve my problem please...?

-- 
View this message in context: http://old.nabble.com/Did-anyone-have-a-script-to-record-webcame-picture-in-video-files-tp30442622p30442622.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list