I am developing an application that captures images of the webcamera and is called Imgp0.jpg, Imgp1.jpg But when I try to convert these images to video using ffmpeg but the video out put is empty. This is the code I use to convert
Imports System.IO
Public Class Form2
Dim mydataandtimeforsave As String = DateTime.Now.ToString("yyyyMMddHHmmss")
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If TextBox1.Text = "" Then
TextBox1.Text = 1
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
capturex()
save()
End Sub
Public Sub capturex()
Dim area As Rectangle
Dim capture As System.Drawing.Bitmap
Dim graph As Graphics
area = Form1.Bounds
capture = New System.Drawing.Bitmap(area.Width, area.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(capture)
graph.CopyFromScreen(area.X, area.Y, 0, 0, area.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = capture
End Sub
Public Sub save()
Dim mydataandtimeforsave = DateTime.Now.ToString("yyyyMMddHHmmss")
PictureBox1.Image.Save("C:\dirorg/" & mydataandtimeforsave & "Screenshot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Me.Timer1.Interval = TimeSpan.FromSeconds(TextBox1.Text).TotalMilliseconds
capturex()
save()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
renameFilesInFolder()
'-framerate 3 -i "Imgp%%04d.jpg" -s 720x480 test.avi)
End Sub
Private Sub renameFilesInFolder()
Dim sourcePath As String = "C:\dirorg/"
Dim searchPattern As String = "*.jpg"
Dim i As Integer = 0
For Each fileName As String In Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories)
File.Move(Path.Combine(sourcePath, fileName), Path.Combine(sourcePath, "Imgp" & i & ".jpg"))
i += 1
Next
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
build()
End Sub
Public Sub build()
Dim args As String 'declare args
args = " -start_number -i C:\dirorg\Imgp%01d.jpg -c:v libx264 -r 1 -pix_fmt yuv420p C:\dirorg\out.mp4 "
Dim proc As New Process
Dim proci As New ProcessStartInfo
proci.FileName = "C:\dirorg\ffmpeg.exe"
proci.Arguments = args
proci.WindowStyle = ProcessWindowStyle.Hidden
proci.CreateNoWindow = True
proci.UseShellExecute = False
proc.StartInfo = proci
proc.Start()
Do Until proc.HasExited = True
Me.Text = "Saving"
Loop
Me.Text = "your video done"
MsgBox("Done")
End Sub
End Class