Dim vf As String = cboVideoFiles.Items.Get(f) 'video file name
Dim piece As Long = videotime2 - videotime1 'ticks
Dim freq As Float = split_qty / (piece/1000)
Dim output_file As String = File.Combine(output_folder, "output_" & DateTime.Now & "_" & DeviceID & "_%05d" & ".jpg")
Slice(TicksToTime(videotime1), File.Combine(ProjectFolder, vf), freq, output_file)
Sub Slice(from As String, video As String, freq As String, out As String)
'ffmpeg -i input_file.mp4 -ss 00:03:45 -vframes 1 output.jpg
Dim ff As String = File.Combine(ffmpeg_folder, "ffmpeg.exe")
Dim Args As List
Args.Initialize
Args.Add("-ss")
Args.Add(from) 'seconds
Args.Add("-i")
Args.Add(video)
Args.Add("-r")
Args.Add(NumberFormat2(freq, 1, 2, 2, False))
Args.Add("-qscale:v")
Args.Add("5") '3=86%, 5=76% JPG quality
Args.Add("-vframes")
Args.Add((split_qty + 1).As(String))
Args.Add(File.GetName(out))
Dim sh As Shell
sh.Initialize("ffmpeg", ff, Args)
sh.WorkingDirectory = File.GetFileParent(out)
sh.Run(-1)
wait for ffmpeg_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
End Sub
Sub TicksToTime (t As Long) As String
Dim hours As Int = t / 1000 / 60 / 60
Dim mins As Int = ((t / 1000) - (hours * 60 * 60)) / 60
Dim secs As Int = ((t / 1000) - (hours * 60 * 60) - (mins * 60))
Dim msecs As Float = ((t / 1000) - (hours * 60 * 60) - (mins * 60) - secs) * 1000
Dim res As String = NumberFormat2(hours, 2, 0, 0, False) & ":" & NumberFormat2(mins, 2, 0, 0, False) & ":" & NumberFormat2(secs, 2, 0, 0, False)
Return res
End Sub