ASP NET, NET Framework, MONO, SQL, Visual Studio | Professional Programming | Viacheslav Eremin
(Notes) Notes (2011 год)

SimpleVideoConverter - простой видеоконвертер на платформе FFMPEG

Eclipse

Этот простейший из возможных видеоконвертеров я сделал на OpenSource платформе FFMPEG. Эта старейшая бесплатная платформа видеоконвертации лишь немногим уступает платным платформам (Adobe, MediaCoder и прочим)

Реальные медиаконвертеры устроены существенно сложнее и содержат десятки тысяч строк кода - выполняются на отдельных виртуальных машинах (чтобы не загружать процессоры web-сервера и sql-сервера), опрашивают очередь запросов на конвертацию, анализируют форматы поступивших на конвертацию файлов и передают запросы собственно сервису видеоконвертации. А эта программа устроена самым минималистским образом - конвертация производится прямо в процессе рабочего стола. Такой минимализм и простота позволяют легко расширять эту прогу в любую сторону.

Несмотря на свою простоту - программа работоспособна и вполне подходит для создания домашней видеотеки.

Учет всех отконвертированных роликов ведется в базе SqLite.


Платформу видеоконвертации FFMPEG (для Win) я установил отсюда - http://ffmpeg.zeranoe.com/builds/ и путь к FFMPEG (D:\FFMPEG\ffmpeg-git-e01f478-win64-shared\bin\) надо указать в параметре конвертера FFMPEG_Path.

В параметре коевертера FFMPEG_Parm указывается шаблон параметров конвертации (по умолчанию я указал -ar 22050 -ab 32K -vcodec libx264 -f flv -b 700k -s XXXxYYY -y).

В параметре конвертера OutDir указывается каталог с итоговыми сконвертированными роликами, а в пераметре MediaDB указывается сктрока коннекта к базе SqLite (в инсталяции у меня вписан путь Data Source="G:\Projects\All_Freeware\SimpleVideoConverter\SimpleVideoConverter\media.s3db";UseUTF16Encoding=True;).

Код основной формы:


   1:  Public Class Startform
   2:   
   3:      Public Property WarningMessage As String
   4:      Public Property Section As String
   5:      Public Property FullFileName As String
   6:      Public Property MediaTitle As String
   7:      Public Property ConvertParm As String
   8:   
   9:      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  10:          Dim CN1 As New System.Data.SQLite.SQLiteConnection(My.Settings.MediaDB)
  11:          CN1.Open()
  12:          Dim CMD1 As New System.Data.SQLite.SQLiteCommand("select * from section;", CN1)
  13:          Dim RDR1 As System.Data.SQLite.SQLiteDataReader = CMD1.ExecuteReader
  14:          While RDR1.Read
  15:              ComboBox1.Items.Add(RDR1("Name"))
  16:          End While
  17:          CN1.Close()
  18:      End Sub
  19:   
  20:      Private Sub SelectVideo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectVideo.Click
  21:          If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  22:              FileName.Text = OpenFileDialog1.FileName
  23:          End If
  24:      End Sub
  25:   
  26:      Private Sub VideoTitle_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles VideoTitle.TextChanged
  27:          Dim Translate = New Translit
  28:          EngName.Text = My.Settings.OutDir & Translate.GetEng(VideoTitle.Text) & ".flv"
  29:          FullFileName = EngName.Text
  30:          MediaTitle = VideoTitle.Text
  31:      End Sub
  32:   
  33:      Private Sub ConvertGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConvertGo.Click
  34:          ConvertParm = My.Settings.FFMPEG_Parm.Replace("XXX", DimensionX.Value).Replace("YYY", DimensionY.Value)
  35:          Dim MediaCoder As New System.Diagnostics.Process
  36:          MediaCoder.StartInfo.FileName = My.Settings.FFMPEG_Path & "ffmpeg.exe"
  37:          MediaCoder.StartInfo.Arguments = " -i " & """" & FileName.Text & """ " & ConvertParm & " """ & EngName.Text & """"
  38:          MediaCoder.StartInfo.WorkingDirectory = My.Application.Info.DirectoryPath
  39:          MediaCoder.StartInfo.UseShellExecute = False
  40:          MediaCoder.StartInfo.RedirectStandardError = True
  41:          Try
  42:              MediaCoder.Start()
  43:              MediaCoder.WaitForExit(1000)
  44:          Catch ex As Exception
  45:              Lerr1.Text = ex.Message
  46:              Exit Sub
  47:          End Try
  48:          Dim RDR1 As IO.StreamReader = MediaCoder.StandardError
  49:          WarningMessage = RDR1.ReadToEnd
  50:          RDR1.Close()
  51:          MediaCoder.Close()
  52:          Dim Msg1 As New MSG
  53:          Msg1.ShowDialog()
  54:      End Sub
  55:   
  56:      Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  57:          Dim formGraphics As Graphics = e.Graphics
  58:          Dim gradientBrush As New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Me.Height), Color.FromArgb(198, 198, 198), Color.FromArgb(146, 146, 146))
  59:          formGraphics.FillRectangle(gradientBrush, ClientRectangle)
  60:      End Sub
  61:   
  62:      Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  63:          Section = ComboBox1.Text
  64:      End Sub
  65:  End Class

Разметка основной формы:


   1:  <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
   2:  Partial Class Startform
   3:      Inherits System.Windows.Forms.Form
   4:   
   5:      'Form overrides dispose to clean up the component list.
   6:      <System.Diagnostics.DebuggerNonUserCode()> _
   7:      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
   8:          Try
   9:              If disposing AndAlso components IsNot Nothing Then
  10:                  components.Dispose()
  11:              End If
  12:          Finally
  13:              MyBase.Dispose(disposing)
  14:          End Try
  15:      End Sub
  16:   
  17:      'Required by the Windows Form Designer
  18:      Private components As System.ComponentModel.IContainer
  19:   
  20:      'NOTE: The following procedure is required by the Windows Form Designer
  21:      'It can be modified using the Windows Form Designer.  
  22:      'Do not modify it using the code editor.
  23:      <System.Diagnostics.DebuggerStepThrough()> _
  24:      Private Sub InitializeComponent()
  25:          Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Startform))
  26:          Me.Label1 = New System.Windows.Forms.Label()
  27:          Me.SelectVideo = New System.Windows.Forms.Button()
  28:          Me.FileName = New System.Windows.Forms.TextBox()
  29:          Me.Label2 = New System.Windows.Forms.Label()
  30:          Me.ComboBox1 = New System.Windows.Forms.ComboBox()
  31:          Me.Label3 = New System.Windows.Forms.Label()
  32:          Me.VideoTitle = New System.Windows.Forms.TextBox()
  33:          Me.Label4 = New System.Windows.Forms.Label()
  34:          Me.EngName = New System.Windows.Forms.Label()
  35:          Me.ConvertGo = New System.Windows.Forms.Button()
  36:          Me.Lerr1 = New System.Windows.Forms.Label()
  37:          Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
  38:          Me.DimensionX = New System.Windows.Forms.NumericUpDown()
  39:          Me.Label5 = New System.Windows.Forms.Label()
  40:          Me.DimensionY = New System.Windows.Forms.NumericUpDown()
  41:          CType(Me.DimensionX, System.ComponentModel.ISupportInitialize).BeginInit()
  42:          CType(Me.DimensionY, System.ComponentModel.ISupportInitialize).BeginInit()
  43:          Me.SuspendLayout()
  44:          '
  45:          'Label1
  46:          '
  47:          Me.Label1.AutoSize = True
  48:          Me.Label1.BackColor = System.Drawing.Color.Transparent
  49:          Me.Label1.ForeColor = System.Drawing.SystemColors.Info
  50:          Me.Label1.Location = New System.Drawing.Point(6, 20)
  51:          Me.Label1.Name = "Label1"
  52:          Me.Label1.Size = New System.Drawing.Size(78, 13)
  53:          Me.Label1.TabIndex = 0
  54:          Me.Label1.Text = "Входной файл"
  55:          '
  56:          'SelectVideo
  57:          '
  58:          Me.SelectVideo.Location = New System.Drawing.Point(102, 16)
  59:          Me.SelectVideo.Name = "SelectVideo"
  60:          Me.SelectVideo.Size = New System.Drawing.Size(75, 23)
  61:          Me.SelectVideo.TabIndex = 1
  62:          Me.SelectVideo.Text = "Open"
  63:          Me.SelectVideo.UseVisualStyleBackColor = True
  64:          '
  65:          'FileName
  66:          '
  67:          Me.FileName.Location = New System.Drawing.Point(200, 18)
  68:          Me.FileName.Name = "FileName"
  69:          Me.FileName.Size = New System.Drawing.Size(369, 20)
  70:          Me.FileName.TabIndex = 2
  71:          '
  72:          'Label2
  73:          '
  74:          Me.Label2.AutoSize = True
  75:          Me.Label2.BackColor = System.Drawing.Color.Transparent
  76:          Me.Label2.ForeColor = System.Drawing.SystemColors.Info
  77:          Me.Label2.Location = New System.Drawing.Point(6, 60)
  78:          Me.Label2.Name = "Label2"
  79:          Me.Label2.Size = New System.Drawing.Size(53, 13)
  80:          Me.Label2.TabIndex = 3
  81:          Me.Label2.Text = "В раздел"
  82:          '
  83:          'ComboBox1
  84:          '
  85:          Me.ComboBox1.DisplayMember = "Name"
  86:          Me.ComboBox1.FormattingEnabled = True
  87:          Me.ComboBox1.Location = New System.Drawing.Point(102, 57)
  88:          Me.ComboBox1.Name = "ComboBox1"
  89:          Me.ComboBox1.Size = New System.Drawing.Size(201, 21)
  90:          Me.ComboBox1.TabIndex = 4
  91:          '
  92:          'Label3
  93:          '
  94:          Me.Label3.AutoSize = True
  95:          Me.Label3.BackColor = System.Drawing.Color.Transparent
  96:          Me.Label3.ForeColor = System.Drawing.SystemColors.Info
  97:          Me.Label3.Location = New System.Drawing.Point(6, 100)
  98:          Me.Label3.Name = "Label3"
  99:          Me.Label3.Size = New System.Drawing.Size(90, 13)
 100:          Me.Label3.TabIndex = 5
 101:          Me.Label3.Text = "Название видео"
 102:          '
 103:          'VideoTitle
 104:          '
 105:          Me.VideoTitle.Location = New System.Drawing.Point(102, 97)
 106:          Me.VideoTitle.Name = "VideoTitle"
 107:          Me.VideoTitle.Size = New System.Drawing.Size(467, 20)
 108:          Me.VideoTitle.TabIndex = 6
 109:          '
 110:          'Label4
 111:          '
 112:          Me.Label4.AutoSize = True
 113:          Me.Label4.BackColor = System.Drawing.Color.Transparent
 114:          Me.Label4.ForeColor = System.Drawing.SystemColors.Info
 115:          Me.Label4.Location = New System.Drawing.Point(6, 140)
 116:          Me.Label4.Name = "Label4"
 117:          Me.Label4.Size = New System.Drawing.Size(86, 13)
 118:          Me.Label4.TabIndex = 7
 119:          Me.Label4.Text = "Итоговый файл"
 120:          '
 121:          'EngName
 122:          '
 123:          Me.EngName.AutoSize = True
 124:          Me.EngName.BackColor = System.Drawing.Color.Transparent
 125:          Me.EngName.Location = New System.Drawing.Point(102, 142)
 126:          Me.EngName.Name = "EngName"
 127:          Me.EngName.Size = New System.Drawing.Size(10, 13)
 128:          Me.EngName.TabIndex = 8
 129:          Me.EngName.Text = "-"
 130:          '
 131:          'ConvertGo
 132:          '
 133:          Me.ConvertGo.Location = New System.Drawing.Point(385, 181)
 134:          Me.ConvertGo.Name = "ConvertGo"
 135:          Me.ConvertGo.Size = New System.Drawing.Size(75, 23)
 136:          Me.ConvertGo.TabIndex = 9
 137:          Me.ConvertGo.Text = "Convert"
 138:          Me.ConvertGo.UseVisualStyleBackColor = True
 139:          '
 140:          'Lerr1
 141:          '
 142:          Me.Lerr1.AutoSize = True
 143:          Me.Lerr1.BackColor = System.Drawing.Color.Transparent
 144:          Me.Lerr1.ForeColor = System.Drawing.Color.Red
 145:          Me.Lerr1.Location = New System.Drawing.Point(99, 224)
 146:          Me.Lerr1.Name = "Lerr1"
 147:          Me.Lerr1.Size = New System.Drawing.Size(0, 13)
 148:          Me.Lerr1.TabIndex = 10
 149:          '
 150:          'OpenFileDialog1
 151:          '
 152:          Me.OpenFileDialog1.FileName = "OpenFileDialog1"
 153:          Me.OpenFileDialog1.Filter = "All files (*.*)|*.*"
 154:          '
 155:          'DimensionX
 156:          '
 157:          Me.DimensionX.Location = New System.Drawing.Point(105, 182)
 158:          Me.DimensionX.Maximum = New Decimal(New Integer() {800, 0, 0, 0})
 159:          Me.DimensionX.Minimum = New Decimal(New Integer() {150, 0, 0, 0})
 160:          Me.DimensionX.Name = "DimensionX"
 161:          Me.DimensionX.Size = New System.Drawing.Size(84, 20)
 162:          Me.DimensionX.TabIndex = 11
 163:          Me.DimensionX.Value = New Decimal(New Integer() {450, 0, 0, 0})
 164:          '
 165:          'Label5
 166:          '
 167:          Me.Label5.AutoSize = True
 168:          Me.Label5.BackColor = System.Drawing.Color.Transparent
 169:          Me.Label5.ForeColor = System.Drawing.SystemColors.Info
 170:          Me.Label5.Location = New System.Drawing.Point(12, 184)
 171:          Me.Label5.Name = "Label5"
 172:          Me.Label5.Size = New System.Drawing.Size(32, 13)
 173:          Me.Label5.TabIndex = 12
 174:          Me.Label5.Text = "X / Y"
 175:          '
 176:          'DimensionY
 177:          '
 178:          Me.DimensionY.Location = New System.Drawing.Point(219, 182)
 179:          Me.DimensionY.Maximum = New Decimal(New Integer() {600, 0, 0, 0})
 180:          Me.DimensionY.Minimum = New Decimal(New Integer() {100, 0, 0, 0})
 181:          Me.DimensionY.Name = "DimensionY"
 182:          Me.DimensionY.Size = New System.Drawing.Size(84, 20)
 183:          Me.DimensionY.TabIndex = 13
 184:          Me.DimensionY.Value = New Decimal(New Integer() {376, 0, 0, 0})
 185:          '
 186:          'Startform
 187:          '
 188:          Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
 189:          Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
 190:          Me.ClientSize = New System.Drawing.Size(611, 262)
 191:          Me.Controls.Add(Me.DimensionY)
 192:          Me.Controls.Add(Me.Label5)
 193:          Me.Controls.Add(Me.DimensionX)
 194:          Me.Controls.Add(Me.Lerr1)
 195:          Me.Controls.Add(Me.ConvertGo)
 196:          Me.Controls.Add(Me.EngName)
 197:          Me.Controls.Add(Me.Label4)
 198:          Me.Controls.Add(Me.VideoTitle)
 199:          Me.Controls.Add(Me.Label3)
 200:          Me.Controls.Add(Me.ComboBox1)
 201:          Me.Controls.Add(Me.Label2)
 202:          Me.Controls.Add(Me.FileName)
 203:          Me.Controls.Add(Me.SelectVideo)
 204:          Me.Controls.Add(Me.Label1)
 205:          Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
 206:          Me.Name = "Startform"
 207:          Me.Text = "Simple OpenSource VideoConverter on FFMPEG platform (http://asp-net.ru/)"
 208:          CType(Me.DimensionX, System.ComponentModel.ISupportInitialize).EndInit()
 209:          CType(Me.DimensionY, System.ComponentModel.ISupportInitialize).EndInit()
 210:          Me.ResumeLayout(False)
 211:          Me.PerformLayout()
 212:   
 213:      End Sub
 214:      Friend WithEvents Label1 As System.Windows.Forms.Label
 215:      Friend WithEvents SelectVideo As System.Windows.Forms.Button
 216:      Friend WithEvents FileName As System.Windows.Forms.TextBox
 217:      Friend WithEvents Label2 As System.Windows.Forms.Label
 218:      Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
 219:      Friend WithEvents Label3 As System.Windows.Forms.Label
 220:      Friend WithEvents VideoTitle As System.Windows.Forms.TextBox
 221:      Friend WithEvents Label4 As System.Windows.Forms.Label
 222:      Friend WithEvents EngName As System.Windows.Forms.Label
 223:      Friend WithEvents ConvertGo As System.Windows.Forms.Button
 224:      Friend WithEvents Lerr1 As System.Windows.Forms.Label
 225:      Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
 226:      Friend WithEvents DimensionX As System.Windows.Forms.NumericUpDown
 227:      Friend WithEvents Label5 As System.Windows.Forms.Label
 228:      Friend WithEvents DimensionY As System.Windows.Forms.NumericUpDown
 229:   
 230:  End Class
 231:   

Код второй формы с сообщением:


   1:  Public Class MSG
   2:   
   3:      Private Sub MSG_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   4:          TextBox1.Text = Startform.WarningMessage
   5:      End Sub
   6:   
   7:      Private Sub btOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOK.Click
   8:          Dim CN1 As New System.Data.SQLite.SQLiteConnection(My.Settings.MediaDB)
   9:          CN1.Open()
  10:          Dim CMD1 As New System.Data.SQLite.SQLiteCommand("insert into media (CrDate, ToSection, Title, FileName, ConvertParm) VALUES (date('now'),""" & Startform.Section & """,""" & Startform.MediaTitle & """,""" & Startform.FullFileName & """,""" & Startform.ConvertParm & """)", CN1)
  11:          Dim RDR1 As System.Data.SQLite.SQLiteDataReader = CMD1.ExecuteReader
  12:          CN1.Close()
  13:          Me.Close()
  14:      End Sub
  15:   
  16:      Private Sub btNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btNo.Click
  17:          Me.Close()
  18:      End Sub
  19:  End Class

Разметка второй формы:


   1:  <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
   2:  Partial Class MSG
   3:      Inherits System.Windows.Forms.Form
   4:   
   5:      'Form overrides dispose to clean up the component list.
   6:      <System.Diagnostics.DebuggerNonUserCode()> _
   7:      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
   8:          Try
   9:              If disposing AndAlso components IsNot Nothing Then
  10:                  components.Dispose()
  11:              End If
  12:          Finally
  13:              MyBase.Dispose(disposing)
  14:          End Try
  15:      End Sub
  16:   
  17:      'Required by the Windows Form Designer
  18:      Private components As System.ComponentModel.IContainer
  19:   
  20:      'NOTE: The following procedure is required by the Windows Form Designer
  21:      'It can be modified using the Windows Form Designer.  
  22:      'Do not modify it using the code editor.
  23:      <System.Diagnostics.DebuggerStepThrough()> _
  24:      Private Sub InitializeComponent()
  25:          Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MSG))
  26:          Me.Splitter1 = New System.Windows.Forms.Splitter()
  27:          Me.btOK = New System.Windows.Forms.Button()
  28:          Me.btNo = New System.Windows.Forms.Button()
  29:          Me.TextBox1 = New System.Windows.Forms.TextBox()
  30:          Me.Label1 = New System.Windows.Forms.Label()
  31:          Me.SuspendLayout()
  32:          '
  33:          'Splitter1
  34:          '
  35:          Me.Splitter1.Dock = System.Windows.Forms.DockStyle.Bottom
  36:          Me.Splitter1.Location = New System.Drawing.Point(0, 257)
  37:          Me.Splitter1.Name = "Splitter1"
  38:          Me.Splitter1.Size = New System.Drawing.Size(815, 60)
  39:          Me.Splitter1.TabIndex = 0
  40:          Me.Splitter1.TabStop = False
  41:          '
  42:          'btOK
  43:          '
  44:          Me.btOK.Location = New System.Drawing.Point(321, 282)
  45:          Me.btOK.Name = "btOK"
  46:          Me.btOK.Size = New System.Drawing.Size(75, 23)
  47:          Me.btOK.TabIndex = 1
  48:          Me.btOK.Text = "OK"
  49:          Me.btOK.UseVisualStyleBackColor = True
  50:          '
  51:          'btNo
  52:          '
  53:          Me.btNo.Location = New System.Drawing.Point(418, 282)
  54:          Me.btNo.Name = "btNo"
  55:          Me.btNo.Size = New System.Drawing.Size(75, 23)
  56:          Me.btNo.TabIndex = 2
  57:          Me.btNo.Text = "NO"
  58:          Me.btNo.UseVisualStyleBackColor = True
  59:          '
  60:          'TextBox1
  61:          '
  62:          Me.TextBox1.Dock = System.Windows.Forms.DockStyle.Fill
  63:          Me.TextBox1.Location = New System.Drawing.Point(0, 0)
  64:          Me.TextBox1.Multiline = True
  65:          Me.TextBox1.Name = "TextBox1"
  66:          Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
  67:          Me.TextBox1.Size = New System.Drawing.Size(815, 257)
  68:          Me.TextBox1.TabIndex = 3
  69:          '
  70:          'Label1
  71:          '
  72:          Me.Label1.AutoSize = True
  73:          Me.Label1.ForeColor = System.Drawing.SystemColors.Desktop
  74:          Me.Label1.Location = New System.Drawing.Point(372, 264)
  75:          Me.Label1.Name = "Label1"
  76:          Me.Label1.Size = New System.Drawing.Size(65, 13)
  77:          Me.Label1.TabIndex = 4
  78:          Me.Label1.Text = "Save to db?"
  79:          '
  80:          'MSG
  81:          '
  82:          Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
  83:          Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
  84:          Me.ClientSize = New System.Drawing.Size(815, 317)
  85:          Me.Controls.Add(Me.Label1)
  86:          Me.Controls.Add(Me.TextBox1)
  87:          Me.Controls.Add(Me.btNo)
  88:          Me.Controls.Add(Me.btOK)
  89:          Me.Controls.Add(Me.Splitter1)
  90:          Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
  91:          Me.Name = "MSG"
  92:          Me.Text = "Warning"
  93:          Me.ResumeLayout(False)
  94:          Me.PerformLayout()
  95:   
  96:      End Sub
  97:      Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
  98:      Friend WithEvents btOK As System.Windows.Forms.Button
  99:      Friend WithEvents btNo As System.Windows.Forms.Button
 100:      Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
 101:      Friend WithEvents Label1 As System.Windows.Forms.Label
 102:  End Class

app.conf проекта. Обратите внимание на строки 8-10 - они обеспечивают совместимость драйвера SqLite c NET 4.0


   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <configuration>
   3:      <configSections>
   4:          <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
   5:              <section name="SimpleVideoConverter.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   6:          </sectionGroup>
   7:      </configSections>
   8:      <startup useLegacyV2RuntimeActivationPolicy="true">
   9:          <supportedRuntime version="v4.0"  />
  10:      </startup>
  11:      <connectionStrings>
  12:    <add name="SimpleVideoConverter.My.MySettings.MediaDB" connectionString="Data Source=&quot;G:\Projects\All_Freeware\SimpleVideoConverter\SimpleVideoConverter\media.s3db&quot;;UseUTF16Encoding=True;" />
  13:   </connectionStrings>
  14:      <system.diagnostics>
  15:          <sources>
  16:              <!-- This section defines the logging configuration for My.Application.Log -->
  17:              <source name="DefaultSource" switchName="DefaultSwitch">
  18:                  <listeners>
  19:                      <add name="FileLog"/>
  20:                      <!-- Uncomment the below section to write to the Application Event Log -->
  21:                      <!--<add name="EventLog"/>-->
  22:                  </listeners>
  23:              </source>
  24:          </sources>
  25:          <switches>
  26:              <add name="DefaultSwitch" value="Information" />
  27:          </switches>
  28:          <sharedListeners>
  29:              <add name="FileLog"
  30:                   type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
  31:                   initializeData="FileLogWriter"/>
  32:              <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
  33:              <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
  34:          </sharedListeners>
  35:      </system.diagnostics>
  36:      <applicationSettings>
  37:          <SimpleVideoConverter.My.MySettings>
  38:              <setting name="OutDir" serializeAs="String">
  39:                  <value>F:\Media\</value>
  40:              </setting>
  41:              <setting name="FFMPEG_Path" serializeAs="String">
  42:                  <value>D:\FFMPEG\ffmpeg-git-e01f478-win64-shared\bin\</value>
  43:              </setting>
  44:              <setting name="FFMPEG_Parm" serializeAs="String">
  45:                  <value>-ar 22050 -ab 32K -vcodec libx264 -f flv -b 700k -s XXXxYYY -y</value>
  46:              </setting>
  47:          </SimpleVideoConverter.My.MySettings>
  48:      </applicationSettings>
  49:  </configuration>

Небольшая дополнительная функция Translit для транслитерации наименования ролика в название его файла на английском языке - вообще говоря не является необходимой для этого минимально конвертера. Эта функция попала сюда из более сложного конвертера с применением FMS (Flash media server) и DVR (закладок на определнных моментах видеоролика). В этом простейшем конвертере, конечно, ничего такого нет - но тем не менее я включил эту функцию для удобства в состав этого конвертера.


   1:  Public Class Translit
   2:   
   3:      Dim Rus() = {"А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ь", "Ы", "Ъ", "Э", "Ю", "Я", "а", "б", "в", "г", "д", "е", "ё", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ь", "ы", "ъ", "э", "ю", "я", ".", "\", "/", "'", """", "!", "%", "^", "&", ")", "(", "=", "{", "}", "|", "~", "`", "@", "#", "$", "+", "*"}
   4:      Dim Eng() = {"A", "B", "V", "G", "D", "E", "JO", "J", "Z", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "H", "C", "4", "SH", "XH", "", "Y", "", "JE", "JU", "JA", "a", "b", "v", "g", "d", "e", "jo", "j", "z", "i", "j", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "c", "4", "sh", "xh", "", "y", "", "je", "ju", "ja", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}
   5:      Dim Ret As System.Text.StringBuilder
   6:   
   7:      Public Function GetEng(ByVal RusInput As String)
   8:          Ret = New System.Text.StringBuilder
   9:          For i As Integer = 0 To RusInput.Length - 1
  10:              Dim IsRus As Boolean = False
  11:              For j As Integer = 0 To Rus.Length - 1
  12:                  If (RusInput.Chars(i) = Rus(j)) Then
  13:                      Ret.Append(Eng(j))
  14:                      IsRus = True
  15:                      Exit For
  16:                  End If
  17:              Next
  18:              If Not IsRus Then
  19:                  Ret.Append(RusInput.Chars(i))
  20:              End If
  21:          Next
  22:          Return Ret.ToString
  23:      End Function
  24:   
  25:  End Class

База проекта включена в MSI-файл и выглядит вот так:




Комментарии к этой страничке ( )
ссылка на эту страничку: http://www.vb-net.ru/SimpleVideoConverter/index.htm
<На главную>  <В раздел ASP>  <В раздел NET>  <В раздел SQL>  <В раздел Разное>  <Написать автору>  < Поблагодарить>