myFFDrop源代码(VB.NET)
2015-07-30 21:55
561 查看
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
相关文章推荐
- [VBS]带参数删除扩展名不是*.h、*.c、*.cpp的全部文件
- [VBS]脚本中的字典、动态数组、队列和堆栈
- 调用windows的sapi制作单词朗读应用
- VBA 里如何正确显示日语
- H.264码流:VBR、ABR、CBR
- VB中WinSock控件的属性、方法、事件及应用
- VB.NET的拖放操作
- vbox快照使用
- VBS_动态数组详解
- 使用命令行WScript和vbs创建快捷方式
- VBA学习中的一些小经验
- VBScript-----妙用SendKeys简化重复操作
- VB中API函数的调用
- mapgis组件开发vb示例
- 利用VBoxManage对虚拟机格式vdi、vmdk、vhd进行互转
- Anti_flicker(去水波纹即闪光)与HB,VB与CLK的关系
- vb查找注册表键值
- VB6 API获取并口、串口端口名和友好名
- VBA与宏
- 53.启动不完全的问题 btn高亮渲染 NavBar风格设置