#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Button1 As Button
Private Button2 As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
End Sub
Sub Button1_Click
Get_Frame
End Sub
Sub Get_Frame()
Dim URL As String = "rtsp://192.168.1.168:554/ch01/0"
'Dim command As String = "/usr/bin/ffmpeg -rtsp_transport tcp -i " & URL & " -r 1 -vsync 1 -qscale 1 -frames:v 1 -f image2 images_$(date +%F_%H-%M-%S).jpg"
If DetectOS = "linux" Then
Dim ff As String = "/usr/bin/ffmpeg"
Else
Dim ff As String = File.Combine(File.GetFileParent(File.DirApp), "/ffmpeg/bin/ffmpeg.exe")
End If
Dim Args As List
Args.Initialize
Args.Add("-rtsp_transport")
Args.Add("tcp")
Args.Add("-i")
Args.Add(QUOTE & URL & QUOTE)
Args.Add("-r")
Args.Add("4") 'try for 10fps
Args.Add("images_%01d.jpg")
Dim sh As Shell
sh.Initialize("ffmpeg", ff, Args)
sh.WorkingDirectory = File.DirApp
sh.Run(-1)
'Dim res As ShellSyncResult =
' #if Debug
' Log(res.Success & "; ExitCode = " & res.ExitCode)
' Log("StdOut = " & res.StdOut)
' Log("StdErr = " & res.StdErr)
' #end if
End Sub
Sub Get_Stamp As String
Dim b As String, d, E As Long, f As Float
DateTime.DateFormat = "yyyy-MM-dd"
DateTime.TimeFormat = "HH-mm-ss"
d = DateTime.Now
E = d - DateTime.TimeParse(DateTime.Time(d))
f = E/DateTime.TicksPerSecond
b = NumberFormat(f, 0, 3)
Dim stamp As String = DateTime.DAte(d) & " " & DateTime.Time(d) & b
Return stamp
End Sub
Private Sub Button2_Click
Dim ff As String = "taskkill.exe"
Dim Args As List
Args.Initialize
Args.Add("/F")
Args.Add("/IM")
Args.Add("ffmpeg.exe")
Dim sh As Shell
sh.Initialize("tk", ff, Args)
sh.WorkingDirectory = "c:\windows\system32"
sh.Run(-1)
End Sub
Sub DetectOS As String
Dim os As String = GetSystemProperty("os.name", "").ToLowerCase
If os.Contains("win") Then
Return "windows"
Else If os.Contains("mac") Then
Return "mac"
Else
Return "linux"
End If
End Sub