myFFDrop源代码(VB.NET)

11 篇文章 0 订阅
6 篇文章 0 订阅
myFFDrop - a ffmpeg frontend
Imports DropTest.myDir
Imports DropTest.myDragDrop
Imports DropTest.myProc
Imports DropTest.Encoding_Parameter

Public Class Form1
    Dim objMyDragDrop As New myDragDrop
    Dim objCmdProc1 As New myProc
    Dim gstrDestFile As String

    Public Event DragEvent(ByVal msg As String)

    Private Sub Init()
        Init_DragDrop()
    End Sub

    Private Sub CloseAll()
        objCmdProc1.kill()
    End Sub

    Private Sub Init_DragDrop()
        Me.AllowDrop = True
        AddHandler Me.DragEnter, AddressOf objMyDragDrop.obj_DragEnter
        AddHandler Me.DragDrop, AddressOf objMyDragDrop.obj_DragDrop
        AddHandler objMyDragDrop.retNewList, AddressOf Retr_DragDrop
        AddHandler objMyDragDrop.retNewFile, AddressOf Proc_DragDrop
    End Sub

    Private Sub Proc_DragDrop(ByVal msg As String)
        If _chkFileExt(msg, ".avi;*.mts;") = True Then
            ListBox1.Items.Add(msg)
        End If
    End Sub

    Private Sub Retr_DragDrop()
        ListBox1.Items.Clear()
    End Sub

    Private Function _chkFileExt(ByVal strPath As String, ByVal strExt As String) As Boolean
        Dim s As String
        For Each s In strExt.Split(";")
            If strPath.EndsWith(s, StringComparison.InvariantCultureIgnoreCase) Then
                Return True
            End If
        Next
        Return False
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Init()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        objCmdProc1.kill()
    End Sub

    Private Sub Invoker(ByVal msg As String)  ' myProc事件委托,负责在两个类之间传递事件信息
        Dim mi As myProc.dlEvntHnd
        mi = New myProc.dlEvntHnd(AddressOf myProc_Evnt)
        If IsNothing(msg) = False Then
            Me.BeginInvoke(mi, msg)
        End If
    End Sub

    Private Sub myProc_Evnt(ByVal msg As String)  ' 由委托触发的事件处理程序
        Dim exitCode As Integer

        If msg.IndexOf("myProc.exitCode") = 0 Then
            exitCode = Val(msg.Substring(16))
            If exitCode <> 0 Then
                TextBox2.AppendText("程序非正常退出。错误号:" + Str(exitCode) + vbCrLf)
                System.IO.File.Delete(gstrDestFile)
            Else
                TextBox2.AppendText("程序正常退出。错误号:" + Str(exitCode) + vbCrLf)
            End If
        End If
        If msg.IndexOf("myProc.errOut") = 0 Then
            TextBox2.AppendText(msg.Substring(14) + vbCrLf)
        End If
        If msg.IndexOf("myProc.stdOut") = 0 Then
            TextBox2.AppendText(msg.Substring(14) + vbCrLf)
        End If
        If msg.IndexOf("myProc.exited") = 0 Then
            TextBox2.AppendText("程序已经退出。" + vbCrLf)
        End If
        If msg.IndexOf("myProc.disposed") = 0 Then
            TextBox2.AppendText("程序已经销毁。" + vbCrLf)
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim i As Integer
        Dim n As Integer
        Dim s As String

        i = ListBox1.SelectedIndex
        n = ListBox1.Items.Count

        If n > 0 Then
            If objCmdProc1.blRunning = False Then
                If i + 1 < n Then

                    i = i + 1
                    ListBox1.SelectedIndex = i
                    s = ListBox1.SelectedItem

                    TextBox1.Text = "正在转换文件" + s + "..."

                    gstrDestFile = s + ".test.mpg"
                    objCmdProc1.run("D:\ffmpeg.exe", getEncArgs(s, gstrDestFile), "")
                    objCmdProc1.hnd(AddressOf Invoker)

                Else
                    ListBox1.Items.Clear()
                End If
            End If
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        CloseAll()
    End Sub
End Class
   
   
    
     _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form 重写 Dispose,以清理组件列表。
    
    
    
     
      _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改它。
    '不要使用代码编辑器修改它。
    
     
     
      
       _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Button1 = New System.Windows.Forms.Button
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(205, 231)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "通马桶"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'ListBox1
        '
        Me.ListBox1.FormattingEnabled = True
        Me.ListBox1.ItemHeight = 12
        Me.ListBox1.Location = New System.Drawing.Point(12, 12)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(318, 208)
        Me.ListBox1.TabIndex = 1
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(336, 12)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(424, 21)
        Me.TextBox1.TabIndex = 2
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(336, 39)
        Me.TextBox2.Multiline = True
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(424, 181)
        Me.TextBox2.TabIndex = 3
        '
        'Timer1
        '
        Me.Timer1.Enabled = True
        Me.Timer1.Interval = 2000
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(772, 266)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents Timer1 As System.Windows.Forms.Timer

End ClassModule Encoding_Parameter

    Public Function getEncArgs(ByVal strSrcFile As String, ByVal strDestFile As String) As String
        Dim cmdLine As String
        cmdLine = "-i """ + strSrcFile + """ -hide_banner"
        cmdLine += " -vcodec mpeg2video -pix_fmt yuv422p -s pal -r pal -flags ilme"
        cmdLine += " -b:v 6000k -bt 100k -maxrate 6000k -strict strict"
        cmdLine += " -g 12 -bf 2 -field_order tt -top 1"
        cmdLine += " -rc_strategy 2 -b_strategy 2 -cmp ""rd"" "
        cmdLine += " -vf """
        'cmdLine += "yadif=mode=1:parity=-1:deint=1,"
        cmdLine += "scale=720:432:flags=lanczos,pad=720:576:0:(oh-ih)/2,interlace"
        'cmdLine += "crop=1440:1080,scale=720:576:flags=sinc"
        cmdLine += """"
        cmdLine += " -acodec mp2 -b:a 384k -ar 48000 -ac 2 -cutoff 14500"
        cmdLine += " -f vob """ + strDestFile + """ -y"
        
        Return cmdLine
    End Function

End Module

     
     
    
    
   
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值