3 Imports System.Diagnostics
\r
4 Imports System.Threading
\r
5 Imports System.ComponentModel
\r
6 Imports System.Windows.Forms
\r
12 Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
\r
13 '# Sets the Version in the bottom corner of the screen.
\r
14 Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
\r
16 '# ----------------------------------------------------
\r
17 '# Updated check on Startup.
\r
18 Dim file_path As String = Application.StartupPath
\r
21 If My.Settings.StartupUpdate = 1 Then
\r
22 ' Download the update file
\r
23 ' open the file for reading and read the first 2 lines for GUI and CLI versions
\r
24 Dim wc As New System.Net.WebClient()
\r
25 wc.DownloadFile("http://download.m0k.org/handbrake/windows/update.txt", file_path & "\update.txt")
\r
27 Dim versionStream As StreamReader = File.OpenText(file_path & "\update.txt")
\r
28 Dim windowsGUI As String = versionStream.ReadLine()
\r
29 Dim windowsCLI As String = versionStream.ReadLine()
\r
30 versionStream.Close()
\r
32 ' If the version is now the same as the one shown here, Display the update label
\r
33 If windowsGUI <> My.Settings.HandbrakeGUIVersion Then
\r
34 lbl_update.Visible = True
\r
35 ElseIf windowsCLI <> My.Settings.HandbrakeCLIVersion Then
\r
36 lbl_update.Visible = True
\r
41 Catch ex As Exception
\r
42 '# No need to alert the user if the update fails. Its just annoying.
\r
45 '#---------------------------------------------------
\r
46 '# Load the Last used Settings
\r
47 '#---------------------------------------------------
\r
49 If My.Settings.UseUsersDefaultSettings = 1 Then
\r
51 text_source.Text = My.Settings.DVDSource
\r
52 drp_dvdtitle.Text = My.Settings.DVDTitle
\r
53 drop_chapterStart.Text = My.Settings.ChapterStart
\r
54 drop_chapterFinish.Text = My.Settings.ChapterFinish
\r
56 text_destination.Text = My.Settings.VideoDest
\r
57 drp_videoEncoder.Text = My.Settings.VideoEncoder
\r
58 drp_audioCodec.Text = My.Settings.AudioEncoder
\r
59 text_width.Text = My.Settings.Width
\r
60 text_height.Text = My.Settings.Height
\r
61 'Picture Settings Tab
\r
62 drp_crop.Text = My.Settings.CroppingOption
\r
63 text_top.Text = My.Settings.CropTop
\r
64 text_bottom.Text = My.Settings.CropBottom
\r
65 text_left.Text = My.Settings.CropLeft
\r
66 text_right.Text = My.Settings.CropRight
\r
67 drp_subtitle.Text = My.Settings.Subtitles
\r
69 text_bitrate.Text = My.Settings.VideoBitrate
\r
70 text_filesize.Text = My.Settings.VideoFilesize
\r
71 slider_videoQuality.Value = My.Settings.VideoQuality
\r
72 check_2PassEncode.CheckState = My.Settings.TwoPass
\r
73 check_DeInterlace.CheckState = My.Settings.DeInterlace
\r
74 check_grayscale.CheckState = My.Settings.Grayscale
\r
75 drp_videoFramerate.Text = My.Settings.Framerate
\r
76 CheckPixelRatio.CheckState = My.Settings.PixelRatio
\r
77 check_turbo.CheckState = My.Settings.turboFirstPass
\r
78 check_largeFile.CheckState = My.Settings.largeFile
\r
80 drp_audioBitrate.Text = My.Settings.AudioBitrate
\r
81 drp_audioSampleRate.Text = My.Settings.AudioSampleRate
\r
82 drp_audioChannels.Text = My.Settings.AudioChannels
\r
84 CheckCRF.CheckState = My.Settings.CRF
\r
85 rtf_h264advanced.Text = My.Settings.H264
\r
87 Catch ex As Exception
\r
88 '# Not actually needed but vb required it to avoid an unhandled exception Interger to String issue. Maybe fix this later
\r
92 '#---------------------------------------------------
\r
93 '# Read DVD at Startup Dialog
\r
94 '#---------------------------------------------------
\r
95 If My.Settings.ReadDVDatStartup = 1 Then
\r
102 '# Any Code relating to the frmMain menu bar
\r
106 Private Sub mnu_exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_exit.Click
\r
110 Private Sub mnu_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_save.Click
\r
112 Dim source As String = text_source.Text
\r
113 Dim dvdTitle As String = drp_dvdtitle.Text
\r
115 Dim ChapterStart As String = drop_chapterStart.Text
\r
116 Dim ChapterFinish As String = drop_chapterFinish.Text
\r
118 Dim destination As String = text_destination.Text
\r
119 Dim videoEncoder As String = drp_videoEncoder.Text
\r
120 Dim audioEncoder As String = drp_audioCodec.Text
\r
121 Dim width As String = text_width.Text
\r
122 Dim height As String = text_height.Text
\r
123 'Picture Settings Tab
\r
124 Dim cropTop As String = text_top.Text
\r
125 Dim cropBottom As String = text_bottom.Text
\r
126 Dim cropLeft As String = text_left.Text
\r
127 Dim cropRight As String = text_right.Text
\r
128 Dim subtitles As String = drp_subtitle.Text
\r
129 'Video Settings Tab
\r
130 Dim videoBitrate As String = text_bitrate.Text
\r
131 Dim videoFilesize As String = text_filesize.Text
\r
132 Dim videoQuality As String = slider_videoQuality.Value
\r
133 Dim twoPassEncoding As String = check_2PassEncode.CheckState
\r
134 Dim deinterlace As String = check_DeInterlace.CheckState
\r
135 Dim grayscale As String = check_grayscale.CheckState
\r
136 Dim videoFramerate As String = drp_videoFramerate.Text
\r
137 Dim pixelRation As String = CheckPixelRatio.CheckState
\r
138 Dim ChapterMarkers As String = Check_ChapterMarkers.CheckState
\r
139 Dim turboH264 As String = check_turbo.CheckState
\r
140 Dim largeFile As String = check_largeFile.CheckState
\r
141 'Audio Settings Tab
\r
142 Dim audioBitrate As String = drp_audioBitrate.Text
\r
143 Dim audioSampleRate As String = drp_audioSampleRate.Text
\r
144 Dim audioChannels As String = drp_audioChannels.Text
\r
145 Dim AudioMixDown As String = drp_audioMixDown.Text
\r
147 Dim CRF As String = CheckCRF.CheckState
\r
148 Dim advH264 As String = rtf_h264advanced.Text
\r
150 Dim filename As String
\r
151 File_Save.ShowDialog()
\r
152 filename = File_Save.FileName
\r
153 If (filename <> "") Then
\r
155 Dim ApplicationPath As String = Application.StartupPath
\r
156 Dim StreamWriter As StreamWriter = File.CreateText(filename)
\r
157 StreamWriter.WriteLine(source)
\r
158 StreamWriter.WriteLine(dvdTitle)
\r
159 StreamWriter.WriteLine(ChapterStart)
\r
160 StreamWriter.WriteLine(ChapterFinish)
\r
161 StreamWriter.WriteLine(destination)
\r
162 StreamWriter.WriteLine(videoEncoder)
\r
163 StreamWriter.WriteLine(audioEncoder)
\r
164 StreamWriter.WriteLine(width)
\r
165 StreamWriter.WriteLine(height)
\r
166 StreamWriter.WriteLine(cropTop)
\r
167 StreamWriter.WriteLine(cropBottom)
\r
168 StreamWriter.WriteLine(cropLeft)
\r
169 StreamWriter.WriteLine(cropRight)
\r
170 StreamWriter.WriteLine(subtitles)
\r
171 StreamWriter.WriteLine(videoBitrate)
\r
172 StreamWriter.WriteLine(videoFilesize)
\r
173 StreamWriter.WriteLine(videoQuality)
\r
174 StreamWriter.WriteLine(twoPassEncoding)
\r
175 StreamWriter.WriteLine(deinterlace)
\r
176 StreamWriter.WriteLine(grayscale)
\r
177 StreamWriter.WriteLine(videoFramerate)
\r
178 StreamWriter.WriteLine(ChapterMarkers)
\r
179 StreamWriter.WriteLine(pixelRation)
\r
180 StreamWriter.WriteLine(turboH264)
\r
181 StreamWriter.WriteLine(largeFile)
\r
182 StreamWriter.WriteLine(audioBitrate)
\r
183 StreamWriter.WriteLine(audioSampleRate)
\r
184 StreamWriter.WriteLine(audioChannels)
\r
185 StreamWriter.WriteLine(AudioMixDown)
\r
186 StreamWriter.WriteLine(CRF)
\r
187 StreamWriter.WriteLine(advH264)
\r
188 StreamWriter.Close()
\r
189 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
\r
191 MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
\r
196 Private Sub mnu_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_open.Click
\r
197 Dim filename As String
\r
198 File_Open.ShowDialog()
\r
199 filename = File_Open.FileName
\r
200 If (filename <> "") Then
\r
202 Dim inputStream As StreamReader = File.OpenText(filename)
\r
204 text_source.Text = inputStream.ReadLine()
\r
205 drp_dvdtitle.Text = inputStream.ReadLine()
\r
206 drop_chapterStart.Text = inputStream.ReadLine()
\r
207 drop_chapterFinish.Text = inputStream.ReadLine()
\r
208 text_destination.Text = inputStream.ReadLine()
\r
209 drp_videoEncoder.Text = inputStream.ReadLine()
\r
210 drp_audioCodec.Text = inputStream.ReadLine()
\r
211 text_width.Text = inputStream.ReadLine()
\r
212 text_height.Text = inputStream.ReadLine()
\r
213 text_top.Text = inputStream.ReadLine()
\r
214 text_bottom.Text = inputStream.ReadLine()
\r
215 text_left.Text = inputStream.ReadLine()
\r
216 text_right.Text = inputStream.ReadLine()
\r
217 drp_subtitle.Text = inputStream.ReadLine()
\r
218 text_bitrate.Text = inputStream.ReadLine()
\r
219 text_filesize.Text = inputStream.ReadLine()
\r
220 slider_videoQuality.Value = inputStream.ReadLine()
\r
221 check_2PassEncode.CheckState = inputStream.ReadLine()
\r
222 check_DeInterlace.CheckState = inputStream.ReadLine()
\r
223 check_grayscale.CheckState = inputStream.ReadLine()
\r
224 drp_videoFramerate.Text = inputStream.ReadLine()
\r
225 Check_ChapterMarkers.CheckState = inputStream.ReadLine()
\r
226 CheckPixelRatio.CheckState = inputStream.ReadLine()
\r
227 check_turbo.CheckState = inputStream.ReadLine()
\r
228 check_largeFile.CheckState = inputStream.ReadLine()
\r
229 drp_audioBitrate.Text = inputStream.ReadLine()
\r
230 drp_audioSampleRate.Text = inputStream.ReadLine()
\r
231 drp_audioChannels.Text = inputStream.ReadLine()
\r
232 drp_audioMixDown.Text = inputStream.ReadLine()
\r
234 'Advanced H264 Options
\r
235 CheckCRF.CheckState = inputStream.ReadLine()
\r
236 rtf_h264advanced.Text = inputStream.ReadLine()
\r
239 ' Fix for SliderValue not appearing when Opening saved file
\r
240 SliderValue.Text = slider_videoQuality.Value & "%"
\r
242 Catch ex As Exception
\r
243 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
\r
249 Private Sub mnu_about_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_about.Click
\r
253 Private Sub mnu_update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_update.Click
\r
257 Private Sub mnu_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_encode.Click
\r
261 Private Sub mnu_ProgramDefaultOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_ProgramDefaultOptions.Click
\r
263 My.Settings.DVDSource = text_source.Text
\r
264 My.Settings.DVDTitle = drp_dvdtitle.Text
\r
265 My.Settings.ChapterStart = drop_chapterStart.Text
\r
266 My.Settings.ChapterFinish = drop_chapterFinish.Text
\r
268 My.Settings.VideoDest = text_destination.Text
\r
269 My.Settings.VideoEncoder = drp_videoEncoder.Text
\r
270 My.Settings.AudioEncoder = drp_audioCodec.Text
\r
271 My.Settings.Width = text_width.Text
\r
272 My.Settings.Height = text_height.Text
\r
273 'Picture Settings Tab
\r
274 My.Settings.CroppingOption = drp_crop.Text
\r
275 My.Settings.CropTop = text_top.Text
\r
276 My.Settings.CropBottom = text_bottom.Text
\r
277 My.Settings.CropLeft = text_left.Text
\r
278 My.Settings.CropRight = text_right.Text
\r
279 My.Settings.Subtitles = drp_subtitle.Text
\r
280 'Video Settings Tab
\r
281 My.Settings.VideoBitrate = text_bitrate.Text
\r
282 My.Settings.VideoFilesize = text_filesize.Text
\r
283 My.Settings.VideoQuality = slider_videoQuality.Value
\r
284 My.Settings.TwoPass = check_2PassEncode.CheckState
\r
285 My.Settings.DeInterlace = check_DeInterlace.CheckState
\r
286 My.Settings.Grayscale = check_grayscale.CheckState
\r
287 My.Settings.Framerate = drp_videoFramerate.Text
\r
288 My.Settings.PixelRatio = CheckPixelRatio.CheckState
\r
289 My.Settings.turboFirstPass = check_turbo.CheckState
\r
290 My.Settings.largeFile = check_largeFile.CheckState
\r
291 'Audio Settings Tab
\r
292 My.Settings.AudioBitrate = drp_audioBitrate.Text
\r
293 My.Settings.AudioSampleRate = drp_audioSampleRate.Text
\r
294 My.Settings.AudioChannels = drp_audioChannels.Text
\r
296 My.Settings.CRF = CheckCRF.CheckState
\r
297 My.Settings.H264 = rtf_h264advanced.Text
\r
301 Private Sub mnu_viewDVDdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_viewDVDdata.Click
\r
306 Private Sub mnu_preset_ipod133_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod133.Click
\r
307 CheckPixelRatio.CheckState = CheckState.Unchecked
\r
308 text_width.Text = "640"
\r
309 text_height.Text = "480"
\r
310 drp_videoEncoder.Text = "H.264 (iPod)"
\r
311 text_bitrate.Text = "1000"
\r
312 text_filesize.Text = ""
\r
313 slider_videoQuality.Value = 0
\r
314 SliderValue.Text = "0%"
\r
315 drp_audioBitrate.Text = "160"
\r
316 rtf_h264advanced.Text = ""
\r
317 drp_crop.Text = "No Crop"
\r
320 Private Sub mnu_preset_ipod178_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod178.Click
\r
321 CheckPixelRatio.CheckState = CheckState.Unchecked
\r
322 text_width.Text = "640"
\r
323 text_height.Text = "352"
\r
324 drp_videoEncoder.Text = "H.264 (iPod)"
\r
325 text_bitrate.Text = "1000"
\r
326 text_filesize.Text = ""
\r
327 slider_videoQuality.Value = 0
\r
328 SliderValue.Text = "0%"
\r
329 drp_audioBitrate.Text = "160"
\r
330 rtf_h264advanced.Text = ""
\r
331 drp_crop.Text = "No Crop"
\r
334 Private Sub mnu_preset_ipod235_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod235.Click
\r
335 CheckPixelRatio.CheckState = CheckState.Unchecked
\r
336 text_width.Text = "640"
\r
337 text_height.Text = "272"
\r
338 drp_videoEncoder.Text = "H.264 (iPod)"
\r
339 text_bitrate.Text = "1000"
\r
340 text_filesize.Text = ""
\r
341 slider_videoQuality.Value = 0
\r
342 SliderValue.Text = "0%"
\r
343 drp_audioBitrate.Text = "160"
\r
344 rtf_h264advanced.Text = ""
\r
345 drp_crop.Text = "No Crop"
\r
348 Private Sub mnu_presetPS3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_presetPS3.Click
\r
349 CheckPixelRatio.CheckState = CheckState.Unchecked
\r
350 text_width.Text = ""
\r
351 text_height.Text = ""
\r
352 drp_videoEncoder.Text = "H.264"
\r
353 text_bitrate.Text = "3000"
\r
354 text_filesize.Text = ""
\r
355 slider_videoQuality.Value = 0
\r
356 SliderValue.Text = "0%"
\r
357 drp_audioBitrate.Text = "160"
\r
358 CheckPixelRatio.CheckState = CheckState.Checked
\r
359 drp_audioSampleRate.Text = "48"
\r
360 rtf_h264advanced.Text = "level=41"
\r
361 drp_crop.Text = "No Crop"
\r
364 Private Sub mnu_appleTv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_appleTv.Click
\r
365 text_width.Text = ""
\r
366 text_height.Text = ""
\r
367 drp_videoEncoder.Text = "H.264"
\r
368 text_bitrate.Text = "3000"
\r
369 text_filesize.Text = ""
\r
370 slider_videoQuality.Value = 0
\r
371 SliderValue.Text = "0%"
\r
372 drp_audioBitrate.Text = "160"
\r
373 CheckPixelRatio.CheckState = CheckState.Checked
\r
374 drp_audioSampleRate.Text = "48"
\r
375 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"
\r
376 drp_crop.Text = "No Crop"
\r
379 Private Sub mnu_options_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_options.Click
\r
383 Private Sub mnu_wiki_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_wiki.Click
\r
384 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac")
\r
387 Private Sub mnu_onlineDocs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_onlineDocs.Click
\r
388 System.Diagnostics.Process.Start("http://handbrake.m0k.org/?page_id=11")
\r
391 Private Sub mnu_homepage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_homepage.Click
\r
392 System.Diagnostics.Process.Start("http://handbrake.m0k.org")
\r
395 Private Sub mnu_forum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_forum.Click
\r
396 System.Diagnostics.Process.Start("http://handbrake.m0k.org/forum")
\r
399 Private Sub mnu_faq_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_faq.Click
\r
400 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq")
\r
405 '# Buttons on the frmMain
\r
409 Private Sub btn_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Browse.Click
\r
410 Dim filename As String
\r
411 text_source.Text = ""
\r
412 If RadioDVD.Checked Then
\r
413 DVD_Open.ShowDialog()
\r
414 filename = DVD_Open.SelectedPath
\r
415 text_source.Text = filename
\r
416 If filename <> "" Then
\r
420 ISO_Open.ShowDialog()
\r
421 filename = ISO_Open.FileName
\r
422 text_source.Text = filename
\r
423 If filename <> "" Then
\r
429 Private Sub btn_destBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_destBrowse.Click
\r
430 Dim filename As String
\r
431 DVD_Save.ShowDialog()
\r
432 filename = DVD_Save.FileName
\r
434 If Check_ChapterMarkers.CheckState = 1 Then
\r
435 filename = filename.Replace(".mp4", ".m4v").Trim()
\r
438 text_destination.Text = filename.Trim
\r
439 Dim DriveLetter() As String = text_destination.Text.Split(":")
\r
442 '# Make sure there is a reasonable amount of space left on the Drive.
\r
445 Dim FileSys = CreateObject("Scripting.FileSystemObject")
\r
448 Drv = FileSys.GetDrive(DriveLetter(0) & ":")
\r
450 Dim lAvailableSpace As Long
\r
451 lAvailableSpace = Drv.AvailableSpace
\r
452 lAvailableSpace = lAvailableSpace / 1024 / 1024 / 1024
\r
453 If lAvailableSpace < 4 Then
\r
454 MessageBox.Show("Low on Disk Space. There is: " & lAvailableSpace & "GB Available", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
457 Dim lTotalSpace As Long
\r
458 lTotalSpace = Drv.TotalSize
\r
462 Catch ex As Exception
\r
463 ' Ignore the Error - Change this to an IF Statment at some point so it works better.
\r
468 Private Sub GenerateQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateQuery.Click
\r
469 Dim query As String = GenerateTheQuery()
\r
470 Dim ApplicationPath As String = Application.StartupPath
\r
471 QueryEditorText.Text = """" + ApplicationPath + "\hbcli.exe""" + query
\r
474 Private Sub btn_ClearQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ClearQuery.Click
\r
475 QueryEditorText.Text = ""
\r
478 Private Sub btn_h264Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_h264Clear.Click
\r
479 rtf_h264advanced.Text = ""
\r
482 Private Sub btn_queue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_queue.Click
\r
483 Dim query As String
\r
484 query = GenerateTheQuery()
\r
485 frmQueue.list_queue.Items.Add(query)
\r
489 Private Sub btn_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_encode.Click
\r
490 Dim query As String
\r
491 Dim ApplicationPath As String = Application.StartupPath
\r
493 If (frmQueue.list_queue.Items.Count > 0) Then
\r
494 MessageBox.Show("You have items on the video queue. If you wish to run the queue please use the encode video button on the queue window." _
\r
495 , "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
499 If (QueryEditorText.Text = "") Then
\r
500 query = GenerateTheQuery()
\r
502 Dim params As String = query
\r
503 Dim proc As New System.Diagnostics.Process
\r
504 proc = System.Diagnostics.Process.Start("""" + ApplicationPath + "\hbcli.exe""", params)
\r
505 If My.Settings.Priority <> "Normal" Then
\r
506 Dim level As String
\r
507 level = My.Settings.Priority
\r
511 proc.PriorityClass = ProcessPriorityClass.RealTime
\r
513 proc.PriorityClass = ProcessPriorityClass.High
\r
514 Case "Above Normal"
\r
515 proc.PriorityClass = ProcessPriorityClass.AboveNormal
\r
516 Case "Below Normal"
\r
517 proc.PriorityClass = ProcessPriorityClass.BelowNormal
\r
519 proc.PriorityClass = ProcessPriorityClass.Idle
\r
525 MessageBox.Show("The Handbrake encoder (CLI) will now start and should be encoding your video.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
\r
527 'Lets start the process monitor to keep an eye on things.
\r
528 hbcliMonitor = New ProcessMonitor()
\r
529 Dim t = New Thread(AddressOf hbcliMonitor.tmrProcCheck)
\r
532 query = QueryEditorText.Text
\r
534 Dim params As String = query
\r
535 Dim proc As New System.Diagnostics.Process
\r
536 proc = System.Diagnostics.Process.Start("""" + ApplicationPath + "\hbcli.exe""", params)
\r
537 MessageBox.Show("The Handbrake encoder (CLI) will now start and should be encoding your video.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
\r
539 'Lets start the process monitor to keep an eye on things.
\r
540 hbcliMonitor = New ProcessMonitor()
\r
541 Dim t = New Thread(AddressOf hbcliMonitor.tmrProcCheck)
\r
544 Catch ex As Exception
\r
545 MessageBox.Show("Unable to launch the HandBrake encoder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
\r
546 MessageBox.Show(ex.ToString) ' Debug
\r
551 Private Sub label_h264_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles label_h264.LinkClicked
\r
552 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options")
\r
557 '# Dynamic stuff on frm Main
\r
561 Private Sub drop_chapterFinish_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drop_chapterFinish.SelectedIndexChanged
\r
562 QueryEditorText.Text = "" ' Just clearing the quert editor box. Users may forget
\r
563 Dim chapterFinish As Integer = drop_chapterFinish.Text
\r
564 Dim chapterStart As Integer = drop_chapterStart.Text
\r
567 If (chapterFinish < chapterStart) Then
\r
568 MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
570 Catch ex As Exception
\r
571 MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
\r
575 Private Sub drop_chapterStart_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drop_chapterStart.SelectedIndexChanged
\r
576 QueryEditorText.Text = "" ' Just clearing the quert editor box. Users may forget
\r
577 Dim chapterFinish As Integer = drop_chapterFinish.Text
\r
578 Dim chapterStart As Integer = drop_chapterStart.Text
\r
580 If (chapterStart > chapterFinish) Then
\r
581 MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
583 Catch ex As Exception
\r
584 MessageBox.Show("Invalid Character Entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
\r
588 Private Sub text_bitrate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_bitrate.TextChanged
\r
589 text_filesize.Text = ""
\r
590 slider_videoQuality.Value = 0
\r
591 SliderValue.Text = "0%"
\r
592 CheckCRF.CheckState = CheckState.Unchecked
\r
595 Private Sub text_filesize_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_filesize.TextChanged
\r
596 text_bitrate.Text = ""
\r
597 slider_videoQuality.Value = 0
\r
598 SliderValue.Text = "0%"
\r
599 CheckCRF.CheckState = CheckState.Unchecked
\r
602 Private Sub slider_videoQuality_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles slider_videoQuality.Scroll
\r
603 SliderValue.Text = slider_videoQuality.Value.ToString + "%"
\r
604 text_bitrate.Text = ""
\r
605 text_filesize.Text = ""
\r
608 Private Sub text_width_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_width.TextChanged
\r
610 If CheckPixelRatio.CheckState = CheckState.Checked Then
\r
611 text_width.Text = ""
\r
614 If (text_width.Text Mod 16) <> 0 Then
\r
615 text_width.BackColor = Color.LightCoral
\r
617 text_width.BackColor = Color.LightGreen
\r
621 If (Not lbl_Aspect.Text.Equals("Select a Title")) Then
\r
622 Dim height As Integer = text_width.Text / lbl_Aspect.Text
\r
623 Dim mod16 As Integer = height Mod 16
\r
624 height = height - mod16
\r
625 text_height.Text = height
\r
628 Catch ex As Exception
\r
633 Private Sub text_height_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_height.TextChanged
\r
635 If CheckPixelRatio.CheckState = CheckState.Checked Then
\r
636 text_height.Text = ""
\r
638 If (text_height.Text Mod 16) <> 0 Then
\r
639 text_height.BackColor = Color.LightCoral
\r
641 text_height.BackColor = Color.LightGreen
\r
644 Catch ex As Exception
\r
650 Private Sub drp_crop_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_crop.SelectedIndexChanged
\r
651 If (drp_crop.SelectedItem = "Manual") Then
\r
652 text_left.Enabled = True
\r
653 text_right.Enabled = True
\r
654 text_top.Enabled = True
\r
655 text_bottom.Enabled = True
\r
658 If (drp_crop.SelectedItem = "Auto Crop") Then
\r
659 text_left.Enabled = False
\r
660 text_right.Enabled = False
\r
661 text_top.Enabled = False
\r
662 text_bottom.Enabled = False
\r
663 text_left.Text = ""
\r
664 text_right.Text = ""
\r
666 text_bottom.Text = ""
\r
668 If lbl_RecomendedCrop.Text <> "Select a Title" Then
\r
669 Dim temp() As String
\r
670 temp = lbl_RecomendedCrop.Text.Split("/")
\r
671 text_left.Text = temp(2)
\r
672 text_right.Text = temp(3)
\r
673 text_top.Text = temp(0)
\r
674 text_bottom.Text = temp(1)
\r
678 If (drp_crop.SelectedItem = "No Crop") Then
\r
679 text_left.Enabled = False
\r
680 text_right.Enabled = False
\r
681 text_top.Enabled = False
\r
682 text_bottom.Enabled = False
\r
683 text_left.Text = "0"
\r
684 text_right.Text = "0"
\r
685 text_top.Text = "0"
\r
686 text_bottom.Text = "0"
\r
691 Private Sub CheckPixelRatio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckPixelRatio.CheckedChanged
\r
692 text_width.Text = ""
\r
693 text_height.Text = ""
\r
694 text_width.BackColor = Color.White
\r
695 text_height.BackColor = Color.White
\r
698 Private Sub drp_dvdtitle_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_dvdtitle.Click
\r
699 If drp_dvdtitle.Items.Count = 1 Then
\r
700 MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
704 Private Sub drp_dvdtitle_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_dvdtitle.SelectedIndexChanged
\r
705 ' If the title changes then the following text values are no longer correct.
\r
706 ' Maybe automatically update these in later versions.
\r
707 lbl_Aspect.Text = "Select a Title"
\r
708 lbl_RecomendedCrop.Text = "Select a Title"
\r
709 QueryEditorText.Text = ""
\r
711 ' Check if there are any titles and alert the user if there is not
\r
714 ' If the title is not automatic then read the dvd.dat file and populate the Subtitles box depending on the title slected.
\r
715 If drp_dvdtitle.Text <> "Automatic" Then
\r
716 Dim temp() As String
\r
717 Dim title As String
\r
718 temp = drp_dvdtitle.Text.Split(" ")
\r
719 title = temp(0).Trim
\r
721 '### Find the line that matches the title number
\r
723 Dim file_path As String = Application.StartupPath
\r
724 Dim ReadFile As StreamReader = File.OpenText(file_path & "\dvd.dat")
\r
725 Dim ReadLine As String = ""
\r
727 ReadLine = ReadFile.ReadLine()
\r
728 While ReadLine <> ""
\r
729 Dim TempLine() As String
\r
730 Dim Tempdata() As String
\r
731 Dim TempCount As Integer
\r
732 Dim counter As Integer = 1
\r
734 TempLine = ReadLine.Split("~")
\r
735 If TempLine(0).Replace("+ ", "").Trim.Equals("title " & title & ":") Then
\r
736 '### Set the 2 Title boxes.
\r
737 Tempdata = TempLine(4).Split("&")
\r
738 TempCount = Tempdata.Length
\r
740 Dim chapterNumber() As String
\r
741 Dim chapter As String
\r
743 drop_chapterStart.Items.Clear()
\r
744 drop_chapterFinish.Items.Clear()
\r
746 drop_chapterStart.Text = "1"
\r
747 drop_chapterFinish.Text = TempCount - 1
\r
750 While counter <> TempCount
\r
751 chapterNumber = Tempdata(counter).Split(":")
\r
752 chapter = chapterNumber(0).Replace("+ ", "").Trim
\r
754 drop_chapterStart.Items.Add(chapter)
\r
755 drop_chapterFinish.Items.Add(chapter)
\r
757 counter = counter + 1
\r
759 counter = 1 ' Reset the counter for reuse
\r
763 '### Here we populate the subtitle box.
\r
764 Tempdata = TempLine(6).Split("&")
\r
765 TempCount = Tempdata.Length
\r
766 ' Cleanup the previous Subtitle Data
\r
767 drp_subtitle.Items.Clear()
\r
768 drp_subtitle.Items.Add("None")
\r
769 drp_subtitle.Text = "None"
\r
771 While counter <> TempCount
\r
772 drp_subtitle.Items.Add(Tempdata(counter).Trim.Replace("+ ", "").Replace(",", ""))
\r
773 counter = counter + 1
\r
775 counter = 1 ' Reset the counter for reuse
\r
777 '### Here we populate the Audio title box
\r
778 Tempdata = TempLine(5).Split("&")
\r
779 TempCount = Tempdata.Length
\r
780 ' Cleanup the previous Subtitle Data
\r
781 drp_audioChannels.Items.Clear()
\r
782 drp_audioChannels.Items.Add("Automatic")
\r
783 drp_audioChannels.Text = "Automatic"
\r
785 While counter <> TempCount
\r
786 Dim temporyvalues() As String = Tempdata(counter).Trim.Replace("+ ", "").Replace(",", "").Split(" ")
\r
787 drp_audioChannels.Items.Add(temporyvalues(0) & " " & temporyvalues(1) & " " & temporyvalues(2) & " " & temporyvalues(3) & ")")
\r
788 counter = counter + 1
\r
790 counter = 1 ' Reset the counter for reuse
\r
792 '### Here we Set the Aspect Ratio text
\r
793 Tempdata = TempLine(2).Split(",")
\r
794 lbl_Aspect.Text = Tempdata(1).Replace(",", "").Replace("aspect: ", "").Trim
\r
796 '### Finally Set the Recommended Crop Text
\r
797 Tempdata = TempLine(3).Split(" ")
\r
798 lbl_RecomendedCrop.Text = Tempdata(3).Replace(",", "").Trim
\r
800 '# Stop the while loop
\r
804 ReadLine = ReadFile.ReadLine()
\r
808 Catch ex As Exception
\r
809 ' No need to display an error, The dropdowns will simply not update if a problem occurs here.
\r
812 ' If Automatic is selected or the user types in the box, then Clear the Subtitle and Audio Dropdowns
\r
813 drp_audioChannels.Items.Clear()
\r
814 drp_audioChannels.Items.Add("Automatic")
\r
815 drp_audioChannels.Text = "Automatic"
\r
816 drp_subtitle.Items.Clear()
\r
817 drp_subtitle.Items.Add("None")
\r
818 drp_subtitle.Text = "None"
\r
822 Private Sub drp_audioCodec_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_audioCodec.SelectedIndexChanged
\r
823 'Dim Channels As String = drp_audioChannels.Text
\r
825 ' If Channels = "Automatic" Then
\r
828 'Dim ChanData() As String = Channels.Trim.Split(" ")
\r
829 'MessageBox.Show(ChanData.Length)
\r
830 'If ChanData.Length <> 0 Then
\r
831 'Channels = ChanData(2).Replace("(", "").Replace(")", "")
\r
832 'MessageBox.Show(Channels)
\r
835 drp_audioMixDown.Items.Clear()
\r
836 If drp_audioCodec.Text = "AAC" Then
\r
837 drp_audioMixDown.Items.Add("Mono")
\r
838 drp_audioMixDown.Items.Add("Stereo")
\r
839 drp_audioMixDown.Items.Add("Dolby Surround")
\r
840 drp_audioMixDown.Items.Add("Dolby Pro Logic II")
\r
841 drp_audioMixDown.Items.Add("6 Channel Discrete")
\r
842 '# Need to impliment
\r
843 '# 5.1 will will show 6ch dpl2
\r
844 '# 5.0 will show dpl2 but not 6ch
\r
845 '# Everything else, mono, stero, dpl1
\r
846 drp_audioBitrate.Items.Clear()
\r
847 drp_audioBitrate.Items.Add("32")
\r
848 drp_audioBitrate.Items.Add("40")
\r
849 drp_audioBitrate.Items.Add("48")
\r
850 drp_audioBitrate.Items.Add("56")
\r
851 drp_audioBitrate.Items.Add("64")
\r
852 drp_audioBitrate.Items.Add("80")
\r
853 drp_audioBitrate.Items.Add("86")
\r
854 drp_audioBitrate.Items.Add("112")
\r
855 drp_audioBitrate.Items.Add("128")
\r
856 drp_audioBitrate.Items.Add("160")
\r
859 drp_audioMixDown.Items.Add("Stereo")
\r
860 drp_audioMixDown.Items.Add("Dolby Surround")
\r
861 drp_audioMixDown.Items.Add("Dolby Pro Logic II")
\r
863 drp_audioBitrate.Items.Clear()
\r
864 drp_audioBitrate.Items.Add("32")
\r
865 drp_audioBitrate.Items.Add("40")
\r
866 drp_audioBitrate.Items.Add("48")
\r
867 drp_audioBitrate.Items.Add("56")
\r
868 drp_audioBitrate.Items.Add("64")
\r
869 drp_audioBitrate.Items.Add("80")
\r
870 drp_audioBitrate.Items.Add("86")
\r
871 drp_audioBitrate.Items.Add("112")
\r
872 drp_audioBitrate.Items.Add("128")
\r
873 drp_audioBitrate.Items.Add("160")
\r
874 drp_audioBitrate.Items.Add("192")
\r
875 drp_audioBitrate.Items.Add("224")
\r
876 drp_audioBitrate.Items.Add("256")
\r
877 drp_audioBitrate.Items.Add("320")
\r
878 drp_audioBitrate.Items.Add("384")
\r
889 Private Sub drp_audioMixDown_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_audioMixDown.SelectedIndexChanged
\r
890 If drp_audioCodec.Text = "AAC" Then
\r
891 If drp_audioMixDown.Text = "6 Channel Discrete" Then
\r
892 drp_audioBitrate.Items.Clear()
\r
893 drp_audioBitrate.Items.Add("32")
\r
894 drp_audioBitrate.Items.Add("40")
\r
895 drp_audioBitrate.Items.Add("48")
\r
896 drp_audioBitrate.Items.Add("56")
\r
897 drp_audioBitrate.Items.Add("64")
\r
898 drp_audioBitrate.Items.Add("80")
\r
899 drp_audioBitrate.Items.Add("86")
\r
900 drp_audioBitrate.Items.Add("112")
\r
901 drp_audioBitrate.Items.Add("128")
\r
902 drp_audioBitrate.Items.Add("160")
\r
903 drp_audioBitrate.Items.Add("192")
\r
904 drp_audioBitrate.Items.Add("224")
\r
905 drp_audioBitrate.Items.Add("256")
\r
906 drp_audioBitrate.Items.Add("320")
\r
907 drp_audioBitrate.Items.Add("384")
\r
912 Private Sub Check_ChapterMarkers_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Check_ChapterMarkers.CheckedChanged
\r
913 Dim destination As String = text_destination.Text
\r
914 If text_destination.Text.Contains(" ") Then
\r
917 destination = destination.Replace(".mp4", ".m4v")
\r
918 text_destination.Text = destination
\r
921 Private Sub check_largeFile_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check_largeFile.Click
\r
922 If (Not text_destination.Text.Contains(".mp4")) Then
\r
923 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
924 check_largeFile.CheckState = CheckState.Unchecked
\r
928 Private Sub check_turbo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check_turbo.Click
\r
929 If (Not drp_videoEncoder.Text.Contains("H.264")) Then
\r
930 MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
931 check_turbo.CheckState = CheckState.Unchecked
\r
935 Private Sub drp_videoEncoder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_videoEncoder.SelectedIndexChanged
\r
936 ' Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
937 If (Not drp_videoEncoder.Text.Contains("H.264")) Then
\r
938 check_turbo.CheckState = CheckState.Unchecked
\r
939 CheckCRF.CheckState = CheckState.Unchecked
\r
943 Private Sub CheckCRF_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckCRF.Click
\r
944 If (slider_videoQuality.Value = 0) Then
\r
945 MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
946 CheckCRF.CheckState = CheckState.Unchecked
\r
956 Function GenerateTheQuery()
\r
959 Dim source As String = text_source.Text
\r
960 Dim dvdTitle As String = drp_dvdtitle.Text
\r
961 Dim chapterStart As String = drop_chapterStart.Text
\r
962 Dim chapterFinish As String = drop_chapterFinish.Text
\r
963 Dim totalChapters As String = drop_chapterFinish.Items.Count - 1
\r
964 Dim dvdChapter As String = ""
\r
968 If (source = "") Then
\r
969 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
971 source = " -i " + """" + source + """"
\r
974 If (dvdTitle = "Automatic") Then
\r
977 Dim titleInfo() As String
\r
978 titleInfo = dvdTitle.Split(" ")
\r
979 dvdTitle = " -t " + titleInfo(0)
\r
982 If (chapterFinish.Equals("Auto") And chapterStart.Equals("Auto")) Then
\r
984 ElseIf (chapterFinish = totalChapters & chapterStart > 1) Then
\r
986 ElseIf chapterFinish = chapterStart Then
\r
987 dvdChapter = " -c " + chapterStart
\r
989 dvdChapter = " -c " + chapterStart + "-" + chapterFinish
\r
992 Dim querySource As String = source + dvdTitle + dvdChapter
\r
993 '----------------------------------------------------------------------
\r
996 Dim destination As String = text_destination.Text
\r
997 Dim videoEncoder As String = drp_videoEncoder.Text
\r
998 Dim audioEncoder As String = drp_audioCodec.Text
\r
999 Dim width As String = text_width.Text
\r
1000 Dim height As String = text_height.Text
\r
1002 If (destination = "") Then
\r
1003 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
\r
1005 destination = " -o " + """" + destination + """"
\r
1008 If (videoEncoder = "Mpeg 4") Then
\r
1009 videoEncoder = " -e ffmpeg"
\r
1010 ElseIf (videoEncoder = "Xvid") Then
\r
1011 videoEncoder = " -e xvid"
\r
1012 ElseIf (videoEncoder = "H.264") Then
\r
1013 videoEncoder = " -e x264"
\r
1014 ElseIf (videoEncoder = "H.264 Baseline 1.3") Then
\r
1015 videoEncoder = " -e x264b13"
\r
1016 ElseIf (videoEncoder = "H.264 (iPod)") Then
\r
1017 videoEncoder = " -e x264b30"
\r
1020 If (audioEncoder = "AAC") Then
\r
1021 audioEncoder = " -E faac"
\r
1022 ElseIf (audioEncoder = "MP3") Then
\r
1023 audioEncoder = " -E lame"
\r
1024 ElseIf (audioEncoder = "Vorbis") Then
\r
1025 audioEncoder = " -E vorbis"
\r
1026 ElseIf (audioEncoder = "AC3") Then
\r
1027 audioEncoder = " -E ac3"
\r
1030 If (width <> "") Then
\r
1031 width = " -w " + width
\r
1034 If (height <> "") Then
\r
1035 height = " -l " + height
\r
1038 Dim queryDestination As String = destination + videoEncoder + audioEncoder + width + height
\r
1039 '----------------------------------------------------------------------
\r
1041 'Picture Settings Tab
\r
1042 Dim cropSetting As String = drp_crop.Text
\r
1043 Dim cropTop As String = text_top.Text
\r
1044 Dim cropBottom As String = text_bottom.Text
\r
1045 Dim cropLeft As String = text_left.Text
\r
1046 Dim cropRight As String = text_right.Text
\r
1047 Dim subtitles As String = drp_subtitle.Text
\r
1048 Dim cropOut As String = "" 'Returns Crop Query
\r
1050 If cropSetting = "Auto Crop" Then
\r
1052 ElseIf cropSetting = "No Crop" Then
\r
1053 cropOut = " --crop 0:0:0:0 "
\r
1055 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight
\r
1058 If (subtitles = "None") Then
\r
1060 ElseIf (subtitles = "") Then
\r
1063 Dim tempSub() As String
\r
1064 tempSub = subtitles.Split(" ")
\r
1065 subtitles = " -s " + tempSub(0)
\r
1068 Dim queryPictureSettings As String = cropOut + subtitles
\r
1069 '----------------------------------------------------------------------
\r
1071 'Video Settings Tab
\r
1072 Dim videoBitrate As String = text_bitrate.Text
\r
1073 Dim videoFilesize As String = text_filesize.Text
\r
1074 Dim videoQuality As String = slider_videoQuality.Value
\r
1075 Dim twoPassEncoding As String = check_2PassEncode.CheckState
\r
1076 Dim deinterlace As String = check_DeInterlace.CheckState
\r
1077 Dim grayscale As String = check_grayscale.CheckState
\r
1078 Dim videoFramerate As String = drp_videoFramerate.Text
\r
1079 Dim pixelRatio As String = CheckPixelRatio.CheckState
\r
1080 Dim ChapterMarkers As String = Check_ChapterMarkers.CheckState
\r
1081 Dim turboH264 As String = check_turbo.CheckState
\r
1082 Dim largeFile As String = check_largeFile.CheckState
\r
1084 If (videoBitrate <> "") Then
\r
1085 videoBitrate = " -b " + videoBitrate
\r
1088 If (videoFilesize <> "") Then
\r
1089 videoFilesize = " -S " + videoFilesize
\r
1092 'Video Quality Setting
\r
1093 If (videoQuality = "0") Then
\r
1096 videoQuality = videoQuality / 100
\r
1097 If videoQuality = 1 Then
\r
1098 videoQuality = "1.0"
\r
1100 videoQuality = " -q " + videoQuality
\r
1103 If (twoPassEncoding = 1) Then
\r
1104 twoPassEncoding = " -2 "
\r
1106 twoPassEncoding = ""
\r
1109 If (deinterlace = 1) Then
\r
1110 deinterlace = " -d "
\r
1115 If (grayscale = 1) Then
\r
1116 grayscale = " -g "
\r
1121 If (videoFramerate = "Automatic") Then
\r
1122 videoFramerate = ""
\r
1124 videoFramerate = " -r " + videoFramerate
\r
1127 If (pixelRatio = 1) Then
\r
1128 pixelRatio = " -p "
\r
1133 If (ChapterMarkers = 1) Then
\r
1134 ChapterMarkers = " -m "
\r
1136 ChapterMarkers = ""
\r
1139 If (turboH264 = 1) Then
\r
1140 turboH264 = " -T "
\r
1145 If (largeFile = 1) Then
\r
1146 largeFile = " -4 "
\r
1152 Dim queryVideoSettings As String = _
\r
1153 videoBitrate + videoFilesize + videoQuality + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile
\r
1154 '----------------------------------------------------------------------
\r
1156 'Audio Settings Tab
\r
1157 Dim audioBitrate As String = drp_audioBitrate.Text
\r
1158 Dim audioSampleRate As String = drp_audioSampleRate.Text
\r
1159 Dim audioChannels As String = drp_audioChannels.Text
\r
1160 Dim Mixdown As String = drp_audioMixDown.Text
\r
1161 Dim SixChannelAudio As String = ""
\r
1163 If (audioBitrate <> "") Then
\r
1164 audioBitrate = " -B " + audioBitrate
\r
1167 If (audioSampleRate <> "") Then
\r
1168 audioSampleRate = " -R " + audioSampleRate
\r
1172 If (audioChannels = "Automatic") Then
\r
1173 audioChannels = ""
\r
1174 ElseIf (audioChannels = "") Then
\r
1175 audioChannels = ""
\r
1177 Dim tempSub() As String
\r
1178 tempSub = audioChannels.Split(" ")
\r
1179 audioChannels = " -a " + tempSub(0)
\r
1183 If (Mixdown = "Automatic") Then
\r
1185 ElseIf Mixdown = "Mono" Then
\r
1187 ElseIf Mixdown = "Stereo" Then
\r
1188 Mixdown = "stereo"
\r
1189 ElseIf Mixdown = "Dolby Surround" Then
\r
1191 ElseIf Mixdown = "Dolby Pro Logic II" Then
\r
1193 ElseIf Mixdown = "6 Channel Discrete" Then
\r
1199 If (Mixdown <> "") Then
\r
1200 SixChannelAudio = " -6 " & Mixdown
\r
1202 SixChannelAudio = ""
\r
1207 Dim queryAudioSettings As String = audioBitrate + audioSampleRate + audioChannels + SixChannelAudio
\r
1208 '----------------------------------------------------------------------
\r
1212 Dim CRF As String = CheckCRF.CheckState
\r
1213 Dim h264Advanced = rtf_h264advanced.Text
\r
1221 If (h264Advanced = "") Then
\r
1224 h264Advanced = " -x " + h264Advanced
\r
1227 Dim h264Settings As String = CRF + h264Advanced
\r
1228 '----------------------------------------------------------------------
\r
1230 'Processors (Program Settings)
\r
1231 Dim processors As String = My.Settings.Processors
\r
1233 ' Number of Processors Handler
\r
1234 If (processors = "Automatic") Then
\r
1237 processors = " -C " + processors + " "
\r
1240 Dim queryAdvancedSettings As String = processors
\r
1241 '----------------------------------------------------------------------
\r
1243 ' Verbose option (Program Settings)
\r
1244 Dim verbose As String = ""
\r
1245 If My.Settings.verbose = 1 Then
\r
1248 '----------------------------------------------------------------------
\r
1251 Return querySource + queryDestination + queryPictureSettings + queryVideoSettings + h264Settings + queryAudioSettings + queryAdvancedSettings + verbose
\r
1258 '# hbcli.exe Handling. Some clever multi-threaded code to monitor the encode process.
\r
1262 ' Lets watch the hbcli process and when it finishes then Raise Event ThreadComplete
\r
1263 Dim WithEvents hbcliMonitor As ProcessMonitor
\r
1264 Public Class ProcessMonitor
\r
1265 Public isRunning As Integer = 1
\r
1267 Public Event ThreadComplete(ByVal isRunning As Integer)
\r
1269 Public Sub tmrProcCheck()
\r
1270 Dim isRunning As Integer
\r
1271 Dim process2 As Process = New Process
\r
1272 Dim running As Boolean = True
\r
1273 Dim hbProcess As Process() = Process.GetProcesses()
\r
1276 Thread.Sleep(1000)
\r
1277 hbProcess = Process.GetProcesses()
\r
1279 Dim processArr2 As Process() = hbProcess
\r
1280 Dim i As Integer = 0
\r
1281 While i < CInt(processArr2.Length)
\r
1282 Dim process1 As Process = processArr2(i)
\r
1283 If process1.ProcessName.Equals("hbcli") Then
\r
1290 RaiseEvent ThreadComplete(isRunning)
\r
1294 ' The hbcli processes has exited at this point. Lets throw a messagebox at the user telling him the enocode has completed.
\r
1295 Sub TheadCompletedMonitor(ByVal isRunning As Integer) Handles hbcliMonitor.ThreadComplete
\r
1296 Dim ApplicationPath As String = Application.StartupPath ' The applications start parth
\r
1297 MessageBox.Show("The encoding process has ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
\r
1300 '-----------------------------------------------
\r