2020年5月19日 星期二

vb.net Process 結束後才進行下一個process [Process finish start next process]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork


        Dim strPath As String = Path.ChangeExtension(AxWindowsMediaPlayer1.URL, "")

        strPath = strPath.Substring(0, strPath.Length - 1)

        Dim blnExit As Boolean = True

        Dim intIndex As Integer = 0


        Dim proc As New Process



        Do

            proc.StartInfo.FileName = Application.StartupPath & "\ffmpeg.exe"

            proc.StartInfo.Arguments = "-y -i " & AxWindowsMediaPlayer1.URL & " -i " & Path.GetDirectoryName(AxWindowsMediaPlayer1.URL) & "\SLogo.png -filter_complex overlay='(main_w)-(overlay_w):(main_h)-(overlay_h)' -ss " & ListView1.Items.Item(intIndex).SubItems(0).Text & " -t " & ListView1.Items.Item(intIndex).SubItems(2).Text & " -async 1 " & strPath & "\" & ListView1.Items.Item(intIndex).SubItems(0).Text.Replace(":", "_") & "-" & ListView1.Items.Item(intIndex).SubItems(2).Text.Replace(":", "_") & ".mp4"

            proc.StartInfo.UseShellExecute = False

            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

            proc.StartInfo.RedirectStandardInput = True

            proc.StartInfo.RedirectStandardOutput = True

            proc.StartInfo.CreateNoWindow = True

            proc.Start()

            proc.WaitForExit()


            If intIndex = ListView1.Items.Count - 1 Then

                blnExit = False

                Exit Do

            Else

                intIndex = intIndex + 1

            End If

        Loop While blnExit


        MsgBox("匯出完成", 64, "完成")

    End Sub

沒有留言:

張貼留言