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
14 '# Sets the Version in the bottom corner of the screen.
\r
15 Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
\r
17 '# ----------------------------------------------------
\r
18 '# Updated check on Startup.
\r
19 Dim file_path As String = Application.StartupPath
\r
22 If My.Settings.StartupUpdate = 1 Then
\r
23 ' Download the update file
\r
24 ' open the file for reading and read the first 2 lines for GUI and CLI versions
\r
25 Dim wc As New System.Net.WebClient()
\r
26 wc.DownloadFile("http://download.m0k.org/handbrake/windows/update.txt", file_path & "\update.txt")
\r
28 Dim versionStream As StreamReader = File.OpenText(file_path & "\update.txt")
\r
29 Dim windowsGUI As String = versionStream.ReadLine()
\r
30 Dim windowsCLI As String = versionStream.ReadLine()
\r
31 versionStream.Close()
\r
33 ' If the version is now the same as the one shown here, Display the update label
\r
34 If windowsGUI <> My.Settings.HandbrakeGUIVersion Then
\r
35 lbl_update.Visible = True
\r
36 ElseIf windowsCLI <> My.Settings.HandbrakeCLIVersion Then
\r
37 lbl_update.Visible = True
\r
42 Catch ex As Exception
\r
43 '# No need to alert the user if the update fails. Its just annoying.
\r
46 '#---------------------------------------------------
\r
47 '# Load the Last used Settings
\r
48 '#---------------------------------------------------
\r
50 If My.Settings.UseUsersDefaultSettings = 1 Then
\r
52 text_source.Text = My.Settings.DVDSource
\r
53 drp_dvdtitle.Text = My.Settings.DVDTitle
\r
54 text_chaptors.Text = My.Settings.DVDChapter
\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
78 drp_audioBitrate.Text = My.Settings.AudioBitrate
\r
79 drp_audioSampleRate.Text = My.Settings.AudioSampleRate
\r
80 drp_audioChannels.Text = My.Settings.AudioChannels
\r
81 Check6ChanAudio.CheckState = My.Settings.FiveChanAudio
\r
82 'Advanced Settings Tab
\r
83 drp_processors.Text = My.Settings.Processors
\r
85 CheckCRF.CheckState = My.Settings.CRF
\r
86 rtf_h264advanced.Text = My.Settings.H264
\r
88 Catch ex As Exception
\r
89 '# Not actually needed but vb required it to avoid an unhandled exception Interger to String issue. Maybe fix this later
\r
93 '#---------------------------------------------------
\r
94 '# Read DVD at Startup Dialog
\r
95 '#---------------------------------------------------
\r
96 If My.Settings.ReadDVDatStartup = 1 Then
\r
103 '# Any Code relating to the frmMain menu bar
\r
107 Private Sub mnu_exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_exit.Click
\r
111 Private Sub mnu_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_save.Click
\r
113 Dim source As String = text_source.Text
\r
114 Dim dvdTitle As String = drp_dvdtitle.Text
\r
115 Dim dvdChaptor As String = text_chaptors.Text
\r
117 Dim destination As String = text_destination.Text
\r
118 Dim videoEncoder As String = drp_videoEncoder.Text
\r
119 Dim audioEncoder As String = drp_audioCodec.Text
\r
120 Dim width As String = text_width.Text
\r
121 Dim height As String = text_height.Text
\r
122 'Picture Settings Tab
\r
123 Dim cropTop As String = text_top.Text
\r
124 Dim cropBottom As String = text_bottom.Text
\r
125 Dim cropLeft As String = text_left.Text
\r
126 Dim cropRight As String = text_right.Text
\r
127 Dim subtitles As String = drp_subtitle.Text
\r
128 'Video Settings Tab
\r
129 Dim videoBitrate As String = text_bitrate.Text
\r
130 Dim videoFilesize As String = text_filesize.Text
\r
131 Dim videoQuality As String = slider_videoQuality.Value
\r
132 Dim twoPassEncoding As String = check_2PassEncode.CheckState
\r
133 Dim deinterlace As String = check_DeInterlace.CheckState
\r
134 Dim grayscale As String = check_grayscale.CheckState
\r
135 Dim videoFramerate As String = drp_videoFramerate.Text
\r
136 Dim pixelRation As String = CheckPixelRatio.CheckState
\r
137 Dim ChapterMarkers As String = Check_ChapterMarkers.CheckState
\r
138 'Audio Settings Tab
\r
139 Dim audioBitrate As String = drp_audioBitrate.Text
\r
140 Dim audioSampleRate As String = drp_audioSampleRate.Text
\r
141 Dim audioChannels As String = drp_audioChannels.Text
\r
142 Dim enabled6chanAudio As String = Check6ChanAudio.CheckState
\r
143 Dim AudioMixDown As String = drp_audioMixDown.Text
\r
144 'Advanced Settings Tab
\r
145 Dim processors As String = drp_processors.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(dvdChaptor)
\r
160 StreamWriter.WriteLine(destination)
\r
161 StreamWriter.WriteLine(videoEncoder)
\r
162 StreamWriter.WriteLine(audioEncoder)
\r
163 StreamWriter.WriteLine(width)
\r
164 StreamWriter.WriteLine(height)
\r
165 StreamWriter.WriteLine(cropTop)
\r
166 StreamWriter.WriteLine(cropBottom)
\r
167 StreamWriter.WriteLine(cropLeft)
\r
168 StreamWriter.WriteLine(cropRight)
\r
169 StreamWriter.WriteLine(subtitles)
\r
170 StreamWriter.WriteLine(videoBitrate)
\r
171 StreamWriter.WriteLine(videoFilesize)
\r
172 StreamWriter.WriteLine(videoQuality)
\r
173 StreamWriter.WriteLine(twoPassEncoding)
\r
174 StreamWriter.WriteLine(deinterlace)
\r
175 StreamWriter.WriteLine(grayscale)
\r
176 StreamWriter.WriteLine(videoFramerate)
\r
177 StreamWriter.WriteLine(ChapterMarkers) '# Fixed Pixel Ratio not saved bug
\r
178 StreamWriter.WriteLine(pixelRation)
\r
179 StreamWriter.WriteLine(audioBitrate)
\r
180 StreamWriter.WriteLine(audioSampleRate)
\r
181 StreamWriter.WriteLine(audioChannels)
\r
182 StreamWriter.WriteLine(enabled6chanAudio)
\r
183 StreamWriter.WriteLine(AudioMixDown)
\r
184 StreamWriter.WriteLine(processors)
\r
185 StreamWriter.WriteLine(CRF)
\r
186 StreamWriter.WriteLine(advH264)
\r
187 StreamWriter.Close()
\r
188 MessageBox.Show("STATUS: Your profile has been sucessfully saved.")
\r
190 MessageBox.Show("ERROR: Unable to write to the file. Please make sure the location has the correct permissions for file writing.")
\r
195 Private Sub mnu_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_open.Click
\r
196 Dim filename As String
\r
197 File_Open.ShowDialog()
\r
198 filename = File_Open.FileName
\r
199 If (filename <> "") Then
\r
201 Dim inputStream As StreamReader = File.OpenText(filename)
\r
203 text_source.Text = inputStream.ReadLine()
\r
204 drp_dvdtitle.Text = inputStream.ReadLine()
\r
205 text_chaptors.Text = inputStream.ReadLine()
\r
206 text_destination.Text = inputStream.ReadLine()
\r
207 drp_videoEncoder.Text = inputStream.ReadLine()
\r
208 drp_audioCodec.Text = inputStream.ReadLine()
\r
209 text_width.Text = inputStream.ReadLine()
\r
210 text_height.Text = inputStream.ReadLine()
\r
211 text_top.Text = inputStream.ReadLine()
\r
212 text_bottom.Text = inputStream.ReadLine()
\r
213 text_left.Text = inputStream.ReadLine()
\r
214 text_right.Text = inputStream.ReadLine()
\r
215 drp_subtitle.Text = inputStream.ReadLine()
\r
216 text_bitrate.Text = inputStream.ReadLine()
\r
217 text_filesize.Text = inputStream.ReadLine()
\r
218 slider_videoQuality.Value = inputStream.ReadLine()
\r
219 check_2PassEncode.CheckState = inputStream.ReadLine()
\r
220 check_DeInterlace.CheckState = inputStream.ReadLine()
\r
221 check_grayscale.CheckState = inputStream.ReadLine()
\r
222 drp_videoFramerate.Text = inputStream.ReadLine()
\r
223 CheckPixelRatio.CheckState = inputStream.ReadLine() '# Fix for pixel ratio not being saved
\r
224 Check_ChapterMarkers.CheckState = inputStream.ReadLine()
\r
225 drp_audioBitrate.Text = inputStream.ReadLine()
\r
226 drp_audioSampleRate.Text = inputStream.ReadLine()
\r
227 drp_audioChannels.Text = inputStream.ReadLine()
\r
228 Check6ChanAudio.CheckState = inputStream.ReadLine()
\r
229 drp_audioMixDown.Text = inputStream.ReadLine()
\r
230 drp_processors.Text = inputStream.ReadLine()
\r
232 'Advanced H264 Options
\r
233 CheckCRF.CheckState = inputStream.ReadLine()
\r
234 rtf_h264advanced.Text = inputStream.ReadLine()
\r
237 ' Fix for SliderValue not appearing when Opening saved file
\r
238 SliderValue.Text = slider_videoQuality.Value & "%"
\r
240 Catch ex As Exception
\r
241 MessageBox.Show("ERROR: Unable to load profile.")
\r
247 Private Sub mnu_about_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_about.Click
\r
251 Private Sub mnu_update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_update.Click
\r
255 Private Sub mnu_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_encode.Click
\r
259 Private Sub mnu_ProgramDefaultOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_ProgramDefaultOptions.Click
\r
261 My.Settings.DVDSource = text_source.Text
\r
262 My.Settings.DVDTitle = drp_dvdtitle.Text
\r
263 My.Settings.DVDChapter = text_chaptors.Text
\r
265 My.Settings.VideoDest = text_destination.Text
\r
266 My.Settings.VideoEncoder = drp_videoEncoder.Text
\r
267 My.Settings.AudioEncoder = drp_audioCodec.Text
\r
268 My.Settings.Width = text_width.Text
\r
269 My.Settings.Height = text_height.Text
\r
270 'Picture Settings Tab
\r
271 My.Settings.CroppingOption = drp_crop.Text
\r
272 My.Settings.CropTop = text_top.Text
\r
273 My.Settings.CropBottom = text_bottom.Text
\r
274 My.Settings.CropLeft = text_left.Text
\r
275 My.Settings.CropRight = text_right.Text
\r
276 My.Settings.Subtitles = drp_subtitle.Text
\r
277 'Video Settings Tab
\r
278 My.Settings.VideoBitrate = text_bitrate.Text
\r
279 My.Settings.VideoFilesize = text_filesize.Text
\r
280 My.Settings.VideoQuality = slider_videoQuality.Value
\r
281 My.Settings.TwoPass = check_2PassEncode.CheckState
\r
282 My.Settings.DeInterlace = check_DeInterlace.CheckState
\r
283 My.Settings.Grayscale = check_grayscale.CheckState
\r
284 My.Settings.Framerate = drp_videoFramerate.Text
\r
285 My.Settings.PixelRatio = CheckPixelRatio.CheckState
\r
286 'Audio Settings Tab
\r
287 My.Settings.AudioBitrate = drp_audioBitrate.Text
\r
288 My.Settings.AudioSampleRate = drp_audioSampleRate.Text
\r
289 My.Settings.AudioChannels = drp_audioChannels.Text
\r
290 My.Settings.FiveChanAudio = Check6ChanAudio.CheckState
\r
291 'Advanced Settings Tab
\r
292 My.Settings.Processors = drp_processors.Text
\r
294 My.Settings.CRF = CheckCRF.CheckState
\r
295 My.Settings.H264 = rtf_h264advanced.Text
\r
299 Private Sub mnu_viewDVDdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_viewDVDdata.Click
\r
304 Private Sub mnu_preset_ipod133_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod133.Click
\r
305 text_width.Text = "640"
\r
306 text_height.Text = "480"
\r
307 drp_videoEncoder.Text = "H.264 (iPod)"
\r
308 text_bitrate.Text = "1000"
\r
309 text_filesize.Text = ""
\r
310 slider_videoQuality.Value = 0
\r
311 SliderValue.Text = "0%"
\r
312 drp_audioBitrate.Text = "160"
\r
316 Private Sub mnu_preset_ipod178_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod178.Click
\r
317 text_width.Text = "640"
\r
318 text_height.Text = "352"
\r
319 drp_videoEncoder.Text = "H.264 (iPod)"
\r
320 text_bitrate.Text = "1000"
\r
321 text_filesize.Text = ""
\r
322 slider_videoQuality.Value = 0
\r
323 SliderValue.Text = "0%"
\r
324 drp_audioBitrate.Text = "160"
\r
327 Private Sub mnu_preset_ipod235_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_preset_ipod235.Click
\r
328 text_width.Text = "640"
\r
329 text_height.Text = "272"
\r
330 drp_videoEncoder.Text = "H.264 (iPod)"
\r
331 text_bitrate.Text = "1000"
\r
332 text_filesize.Text = ""
\r
333 slider_videoQuality.Value = 0
\r
334 SliderValue.Text = "0%"
\r
335 drp_audioBitrate.Text = "160"
\r
338 Private Sub mnu_presetPS3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_presetPS3.Click
\r
339 text_width.Text = ""
\r
340 text_height.Text = ""
\r
341 drp_videoEncoder.Text = "H.264"
\r
342 text_bitrate.Text = "3000"
\r
343 text_filesize.Text = ""
\r
344 slider_videoQuality.Value = 0
\r
345 SliderValue.Text = "0%"
\r
346 drp_audioBitrate.Text = "160"
\r
347 CheckPixelRatio.CheckState = CheckState.Checked
\r
348 drp_audioSampleRate.Text = "48"
\r
349 rtf_h264advanced.Text = "level=41"
\r
352 Private Sub mnu_appleTv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_appleTv.Click
\r
353 text_width.Text = ""
\r
354 text_height.Text = ""
\r
355 drp_videoEncoder.Text = "H.264"
\r
356 text_bitrate.Text = "3000"
\r
357 text_filesize.Text = ""
\r
358 slider_videoQuality.Value = 0
\r
359 SliderValue.Text = "0%"
\r
360 drp_audioBitrate.Text = "160"
\r
361 CheckPixelRatio.CheckState = CheckState.Checked
\r
362 drp_audioSampleRate.Text = "48"
\r
363 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"
\r
368 Private Sub mnu_options_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_options.Click
\r
372 Private Sub mnu_wiki_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_wiki.Click
\r
373 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac")
\r
376 Private Sub mnu_onlineDocs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_onlineDocs.Click
\r
377 System.Diagnostics.Process.Start("http://handbrake.m0k.org/?page_id=11")
\r
380 Private Sub mnu_homepage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_homepage.Click
\r
381 System.Diagnostics.Process.Start("http://handbrake.m0k.org")
\r
384 Private Sub mnu_forum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_forum.Click
\r
385 System.Diagnostics.Process.Start("http://handbrake.m0k.org/forum")
\r
388 Private Sub mnu_faq_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_faq.Click
\r
389 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq")
\r
394 '# Buttons on the frmMain
\r
398 Private Sub btn_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Browse.Click
\r
399 Dim filename As String
\r
400 text_source.Text = ""
\r
401 If RadioDVD.Checked Then
\r
402 DVD_Open.ShowDialog()
\r
403 filename = DVD_Open.SelectedPath
\r
404 text_source.Text = filename
\r
405 If filename <> "" Then
\r
409 ISO_Open.ShowDialog()
\r
410 filename = ISO_Open.FileName
\r
411 text_source.Text = filename
\r
412 If filename <> "" Then
\r
418 Private Sub btn_destBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_destBrowse.Click
\r
419 Dim filename As String
\r
420 DVD_Save.ShowDialog()
\r
421 filename = DVD_Save.FileName
\r
422 text_destination.Text = filename.Trim
\r
423 Dim DriveLetter() As String = text_destination.Text.Split(":")
\r
426 '# Make sure there is a reasonable amount of space left on the Drive.
\r
429 Dim FileSys = CreateObject("Scripting.FileSystemObject")
\r
432 Drv = FileSys.GetDrive(DriveLetter(0) & ":")
\r
434 Dim lAvailableSpace As Long
\r
435 lAvailableSpace = Drv.AvailableSpace
\r
436 lAvailableSpace = lAvailableSpace / 1024 / 1024 / 1024
\r
437 If lAvailableSpace < 4 Then
\r
438 MessageBox.Show("Warning: Low on Disk Space. There is: " & lAvailableSpace & "GB Available")
\r
441 Dim lTotalSpace As Long
\r
442 lTotalSpace = Drv.TotalSize
\r
446 Catch ex As Exception
\r
447 ' Ignore the Error - Change this to an IF Statment at some point so it works better.
\r
452 Private Sub GenerateQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateQuery.Click
\r
453 Dim query As String = GenerateTheQuery()
\r
454 Dim ApplicationPath As String = Application.StartupPath
\r
455 QueryEditorText.Text = """" + ApplicationPath + "\hbcli.exe""" + query
\r
458 Private Sub btn_ClearQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ClearQuery.Click
\r
459 QueryEditorText.Text = ""
\r
462 Private Sub btn_h264Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_h264Clear.Click
\r
463 rtf_h264advanced.Text = ""
\r
466 Private Sub btn_queue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_queue.Click
\r
467 Dim query As String
\r
468 'Dim ApplicationPath As String = Application.StartupPath
\r
469 'If (QueryEditorText.Text = "") Then
\r
470 query = GenerateTheQuery()
\r
471 frmQueue.list_queue.Items.Add(query)
\r
473 ' query = QueryEditorText.Text
\r
474 ' frmQueue.list_queue.Items.Add(query)
\r
480 Private Sub btn_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_encode.Click
\r
481 Dim query As String
\r
482 Dim ApplicationPath As String = Application.StartupPath
\r
485 If (QueryEditorText.Text = "") Then
\r
486 query = GenerateTheQuery()
\r
487 Shell("""" + ApplicationPath + "\hbcli.exe""" + query)
\r
488 MessageBox.Show("The Handbrake encoder (CLI) will now start and should be encoding your video.")
\r
490 'Lets start the process monitor to keep an eye on things.
\r
491 hbcliMonitor = New ProcessMonitor()
\r
492 Dim t = New Thread(AddressOf hbcliMonitor.tmrProcCheck)
\r
495 query = QueryEditorText.Text
\r
496 Shell("""" + ApplicationPath + "\hbcli.exe""" + query)
\r
497 MessageBox.Show("The Handbrake encoder (CLI) will now start and should be encoding your video.")
\r
499 Catch ex As Exception
\r
500 MessageBox.Show("Unable to Launch the Encoder.")
\r
501 MessageBox.Show(ex.ToString) ' Debug
\r
506 Private Sub label_h264_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles label_h264.LinkClicked
\r
507 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options")
\r
512 '# Dynamic stuff on frm Main
\r
516 Private Sub text_bitrate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_bitrate.TextChanged
\r
517 text_filesize.Text = ""
\r
518 slider_videoQuality.Value = 0
\r
519 SliderValue.Text = "0%"
\r
522 Private Sub text_filesize_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_filesize.TextChanged
\r
523 text_bitrate.Text = ""
\r
524 slider_videoQuality.Value = 0
\r
525 SliderValue.Text = "0%"
\r
528 Private Sub slider_videoQuality_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles slider_videoQuality.Scroll
\r
529 SliderValue.Text = slider_videoQuality.Value.ToString + "%"
\r
530 text_bitrate.Text = ""
\r
531 text_filesize.Text = ""
\r
534 Private Sub text_width_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_width.TextChanged
\r
536 If CheckPixelRatio.CheckState = CheckState.Checked Then
\r
537 text_width.Text = ""
\r
540 If (text_width.Text Mod 16) <> 0 Then
\r
541 text_width.BackColor = Color.LightCoral
\r
543 text_width.BackColor = Color.LightGreen
\r
547 Catch ex As Exception
\r
553 Private Sub text_height_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles text_height.TextChanged
\r
555 If CheckPixelRatio.CheckState = CheckState.Checked Then
\r
556 text_height.Text = ""
\r
558 If (text_height.Text Mod 16) <> 0 Then
\r
559 text_height.BackColor = Color.LightCoral
\r
561 text_height.BackColor = Color.LightGreen
\r
564 Catch ex As Exception
\r
570 Private Sub drp_crop_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_crop.SelectedIndexChanged
\r
571 If (drp_crop.SelectedItem = "Manual") Then
\r
572 text_left.Enabled = True
\r
573 text_right.Enabled = True
\r
574 text_top.Enabled = True
\r
575 text_bottom.Enabled = True
\r
578 If (drp_crop.SelectedItem = "Auto Crop") Then
\r
579 text_left.Enabled = False
\r
580 text_right.Enabled = False
\r
581 text_top.Enabled = False
\r
582 text_bottom.Enabled = False
\r
583 text_left.Text = ""
\r
584 text_right.Text = ""
\r
586 text_bottom.Text = ""
\r
588 If lbl_RecomendedCrop.Text <> "Select a Title" Then
\r
589 Dim temp() As String
\r
590 temp = lbl_RecomendedCrop.Text.Split("/")
\r
591 text_left.Text = temp(2)
\r
592 text_right.Text = temp(3)
\r
593 text_top.Text = temp(0)
\r
594 text_bottom.Text = temp(1)
\r
598 If (drp_crop.SelectedItem = "No Crop") Then
\r
599 text_left.Enabled = False
\r
600 text_right.Enabled = False
\r
601 text_top.Enabled = False
\r
602 text_bottom.Enabled = False
\r
603 text_left.Text = "0"
\r
604 text_right.Text = "0"
\r
605 text_top.Text = "0"
\r
606 text_bottom.Text = "0"
\r
611 Private Sub CheckPixelRatio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckPixelRatio.CheckedChanged
\r
612 text_width.Text = ""
\r
613 text_height.Text = ""
\r
614 text_width.BackColor = Color.White
\r
615 text_height.BackColor = Color.White
\r
618 Private Sub drp_dvdtitle_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_dvdtitle.SelectedIndexChanged
\r
619 ' If the title changes then the following text values are no longer correct.
\r
620 ' Maybe automatically update these in later versions.
\r
621 lbl_Aspect.Text = "Select a Title"
\r
622 lbl_RecomendedCrop.Text = "Select a Title"
\r
624 ' If the title is not automatic then read the dvd.dat file and populate the Subtitles box depending on the title slected.
\r
625 If drp_dvdtitle.Text <> "Automatic" Then
\r
626 Dim temp() As String
\r
627 Dim title As String
\r
628 temp = drp_dvdtitle.Text.Split(" ")
\r
629 title = temp(0).Trim
\r
631 '### Find the line that matches the title number
\r
633 Dim file_path As String = Application.StartupPath
\r
634 Dim ReadFile As StreamReader = File.OpenText(file_path & "\dvd.dat")
\r
635 Dim ReadLine As String = ""
\r
637 ReadLine = ReadFile.ReadLine()
\r
638 While ReadLine <> ""
\r
639 Dim TempLine() As String
\r
640 Dim Tempdata() As String
\r
641 Dim TempCount As Integer
\r
642 Dim counter As Integer = 1
\r
644 TempLine = ReadLine.Split("~")
\r
645 If TempLine(0).Replace("+ ", "").Trim.Equals("title " & title & ":") Then
\r
647 '### Here we populate the subtitle box.
\r
648 Tempdata = TempLine(6).Split("&")
\r
649 TempCount = Tempdata.Length
\r
650 ' Cleanup the previous Subtitle Data
\r
651 drp_subtitle.Items.Clear()
\r
652 drp_subtitle.Items.Add("None")
\r
653 drp_subtitle.Text = "None"
\r
655 While counter <> TempCount
\r
656 drp_subtitle.Items.Add(Tempdata(counter).Trim.Replace("+ ", "").Replace(",", ""))
\r
657 counter = counter + 1
\r
659 counter = 1 ' Reset the counter for reuse
\r
661 '### Here we populate the Audio title box
\r
662 Tempdata = TempLine(5).Split("&")
\r
663 TempCount = Tempdata.Length
\r
664 ' Cleanup the previous Subtitle Data
\r
665 drp_audioChannels.Items.Clear()
\r
666 drp_audioChannels.Items.Add("Automatic")
\r
667 drp_audioChannels.Text = "Automatic"
\r
669 While counter <> TempCount
\r
670 Dim temporyvalues() As String = Tempdata(counter).Trim.Replace("+ ", "").Replace(",", "").Split(" ")
\r
671 drp_audioChannels.Items.Add(temporyvalues(0) & " " & temporyvalues(1) & " " & temporyvalues(2) & " " & temporyvalues(3) & ")")
\r
672 counter = counter + 1
\r
674 counter = 1 ' Reset the counter for reuse
\r
676 '### Here we Set the Aspect Ratio text
\r
677 Tempdata = TempLine(2).Split(",")
\r
678 lbl_Aspect.Text = Tempdata(1).Replace(",", "").Replace("aspect: ", "").Trim
\r
680 '### Finally Set the Recommended Crop Text
\r
681 Tempdata = TempLine(3).Split(" ")
\r
682 lbl_RecomendedCrop.Text = Tempdata(3).Replace(",", "").Trim
\r
684 '# Stop the while loop
\r
688 ReadLine = ReadFile.ReadLine()
\r
692 Catch ex As Exception
\r
693 ' No need to display an error, The dropdowns will simply not update if a problem occurs here.
\r
696 ' If Automatic is selected or the user types in the box, then Clear the Subtitle and Audio Dropdowns
\r
697 drp_audioChannels.Items.Clear()
\r
698 drp_audioChannels.Items.Add("Automatic")
\r
699 drp_audioChannels.Text = "Automatic"
\r
700 drp_subtitle.Items.Clear()
\r
701 drp_subtitle.Items.Add("None")
\r
702 drp_subtitle.Text = "None"
\r
706 Private Sub drp_audioCodec_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_audioCodec.SelectedIndexChanged
\r
707 'Dim Channels As String = drp_audioChannels.Text
\r
709 ' If Channels = "Automatic" Then
\r
712 'Dim ChanData() As String = Channels.Trim.Split(" ")
\r
713 'MessageBox.Show(ChanData.Length)
\r
714 'If ChanData.Length <> 0 Then
\r
715 'Channels = ChanData(2).Replace("(", "").Replace(")", "")
\r
716 'MessageBox.Show(Channels)
\r
719 drp_audioMixDown.Items.Clear()
\r
720 If drp_audioCodec.Text = "AAC" Then
\r
721 drp_audioMixDown.Items.Add("Mono")
\r
722 drp_audioMixDown.Items.Add("Stereo")
\r
723 drp_audioMixDown.Items.Add("Dolby Surround")
\r
724 drp_audioMixDown.Items.Add("Dolby Pro Logic II")
\r
725 drp_audioMixDown.Items.Add("6 Channel Discrete")
\r
726 '# Need to impliment
\r
727 '# 5.1 will will show 6ch dpl2
\r
728 '# 5.0 will show dpl2 but not 6ch
\r
729 '# Everything else, mono, stero, dpl1
\r
730 drp_audioBitrate.Items.Clear()
\r
731 drp_audioBitrate.Items.Add("32")
\r
732 drp_audioBitrate.Items.Add("40")
\r
733 drp_audioBitrate.Items.Add("48")
\r
734 drp_audioBitrate.Items.Add("56")
\r
735 drp_audioBitrate.Items.Add("64")
\r
736 drp_audioBitrate.Items.Add("80")
\r
737 drp_audioBitrate.Items.Add("86")
\r
738 drp_audioBitrate.Items.Add("112")
\r
739 drp_audioBitrate.Items.Add("128")
\r
740 drp_audioBitrate.Items.Add("160")
\r
743 drp_audioMixDown.Items.Add("Stereo")
\r
744 drp_audioMixDown.Items.Add("Dolby Surround")
\r
745 drp_audioMixDown.Items.Add("Dolby Pro Logic II")
\r
747 drp_audioBitrate.Items.Clear()
\r
748 drp_audioBitrate.Items.Add("32")
\r
749 drp_audioBitrate.Items.Add("40")
\r
750 drp_audioBitrate.Items.Add("48")
\r
751 drp_audioBitrate.Items.Add("56")
\r
752 drp_audioBitrate.Items.Add("64")
\r
753 drp_audioBitrate.Items.Add("80")
\r
754 drp_audioBitrate.Items.Add("86")
\r
755 drp_audioBitrate.Items.Add("112")
\r
756 drp_audioBitrate.Items.Add("128")
\r
757 drp_audioBitrate.Items.Add("160")
\r
758 drp_audioBitrate.Items.Add("192")
\r
759 drp_audioBitrate.Items.Add("224")
\r
760 drp_audioBitrate.Items.Add("256")
\r
761 drp_audioBitrate.Items.Add("320")
\r
762 drp_audioBitrate.Items.Add("384")
\r
773 Private Sub drp_audioMixDown_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drp_audioMixDown.SelectedIndexChanged
\r
774 If drp_audioCodec.Text = "AAC" Then
\r
775 If drp_audioMixDown.Text = "6 Channel Discrete" Then
\r
776 drp_audioBitrate.Items.Clear()
\r
777 drp_audioBitrate.Items.Add("32")
\r
778 drp_audioBitrate.Items.Add("40")
\r
779 drp_audioBitrate.Items.Add("48")
\r
780 drp_audioBitrate.Items.Add("56")
\r
781 drp_audioBitrate.Items.Add("64")
\r
782 drp_audioBitrate.Items.Add("80")
\r
783 drp_audioBitrate.Items.Add("86")
\r
784 drp_audioBitrate.Items.Add("112")
\r
785 drp_audioBitrate.Items.Add("128")
\r
786 drp_audioBitrate.Items.Add("160")
\r
787 drp_audioBitrate.Items.Add("192")
\r
788 drp_audioBitrate.Items.Add("224")
\r
789 drp_audioBitrate.Items.Add("256")
\r
790 drp_audioBitrate.Items.Add("320")
\r
791 drp_audioBitrate.Items.Add("384")
\r
796 Private Sub Check_ChapterMarkers_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Check_ChapterMarkers.CheckedChanged
\r
797 Dim destination As String = text_destination.Text
\r
798 If text_destination.Text.Contains(" ") Then
\r
801 destination = destination.Replace(".mp4", ".m4v")
\r
802 text_destination.Text = destination
\r
811 Function GenerateTheQuery()
\r
814 Dim source As String = text_source.Text
\r
815 Dim dvdTitle As String = drp_dvdtitle.Text
\r
816 Dim dvdChaptor As String = text_chaptors.Text
\r
818 If (source = "") Then
\r
819 MessageBox.Show("ERROR: No Source has been selected.")
\r
821 source = " -i " + """" + source + """"
\r
824 If (dvdTitle = "Automatic") Then
\r
827 Dim titleInfo() As String
\r
828 titleInfo = dvdTitle.Split(" ")
\r
829 dvdTitle = " -t " + titleInfo(0)
\r
832 If (dvdChaptor = "Automatic") Then
\r
834 ElseIf (dvdChaptor = "") Then
\r
837 dvdChaptor = " -c " + dvdChaptor
\r
840 Dim querySource As String = source + dvdTitle + dvdChaptor
\r
841 '----------------------------------------------------------------------
\r
844 Dim destination As String = text_destination.Text
\r
845 Dim videoEncoder As String = drp_videoEncoder.Text
\r
846 Dim audioEncoder As String = drp_audioCodec.Text
\r
847 Dim width As String = text_width.Text
\r
848 Dim height As String = text_height.Text
\r
850 If (destination = "") Then
\r
851 MessageBox.Show("ERROR: No destination has been selected.")
\r
853 destination = " -o " + """" + destination + """"
\r
856 If (videoEncoder = "Mpeg 4") Then
\r
857 videoEncoder = " -e ffmpeg"
\r
858 ElseIf (videoEncoder = "Xvid") Then
\r
859 videoEncoder = " -e xvid"
\r
860 ElseIf (videoEncoder = "H.264") Then
\r
861 videoEncoder = " -e x264"
\r
862 ElseIf (videoEncoder = "H.264 Baseline 1.3") Then
\r
863 videoEncoder = " -e x264b13"
\r
864 ElseIf (videoEncoder = "H.264 (iPod)") Then
\r
865 videoEncoder = " -e x264b30"
\r
868 If (audioEncoder = "AAC") Then
\r
869 audioEncoder = " -E faac"
\r
870 ElseIf (audioEncoder = "MP3") Then
\r
871 audioEncoder = " -E lame"
\r
872 ElseIf (audioEncoder = "Vorbis") Then
\r
873 audioEncoder = " -E vorbis"
\r
874 ElseIf (audioEncoder = "AC3") Then
\r
875 audioEncoder = " -E ac3"
\r
878 If (width <> "") Then
\r
879 width = " -w " + width
\r
882 If (height <> "") Then
\r
883 height = " -l " + height
\r
886 Dim queryDestination As String = destination + videoEncoder + audioEncoder + width + height
\r
887 '----------------------------------------------------------------------
\r
889 'Picture Settings Tab
\r
890 Dim cropSetting As String = drp_crop.Text
\r
891 Dim cropTop As String = text_top.Text
\r
892 Dim cropBottom As String = text_bottom.Text
\r
893 Dim cropLeft As String = text_left.Text
\r
894 Dim cropRight As String = text_right.Text
\r
895 Dim subtitles As String = drp_subtitle.Text
\r
896 Dim cropOut As String = "" 'Returns Crop Query
\r
898 If cropSetting = "Auto Crop" Then
\r
900 ElseIf cropSetting = "No Crop" Then
\r
901 cropOut = " --crop 0:0:0:0 "
\r
903 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight
\r
906 If (subtitles = "None") Then
\r
908 ElseIf (subtitles = "") Then
\r
911 Dim tempSub() As String
\r
912 tempSub = subtitles.Split(" ")
\r
913 subtitles = " -s " + tempSub(0)
\r
916 Dim queryPictureSettings As String = cropOut + subtitles
\r
917 '----------------------------------------------------------------------
\r
919 'Video Settings Tab
\r
920 Dim videoBitrate As String = text_bitrate.Text
\r
921 Dim videoFilesize As String = text_filesize.Text
\r
922 Dim videoQuality As String = slider_videoQuality.Value
\r
923 Dim twoPassEncoding As String = check_2PassEncode.CheckState
\r
924 Dim deinterlace As String = check_DeInterlace.CheckState
\r
925 Dim grayscale As String = check_grayscale.CheckState
\r
926 Dim videoFramerate As String = drp_videoFramerate.Text
\r
927 Dim pixelRatio As String = CheckPixelRatio.CheckState
\r
928 Dim ChapterMarkers As String = Check_ChapterMarkers.CheckState
\r
930 If (videoBitrate <> "") Then
\r
931 videoBitrate = " -b " + videoBitrate
\r
934 If (videoFilesize <> "") Then
\r
935 videoFilesize = " -S " + videoFilesize
\r
938 'Video Quality Setting
\r
939 If (videoQuality = "0") Then
\r
942 videoQuality = videoQuality / 100
\r
943 If videoQuality = 1 Then
\r
944 videoQuality = "1.0"
\r
946 videoQuality = " -q " + videoQuality
\r
949 If (twoPassEncoding = 1) Then
\r
950 twoPassEncoding = " -2 "
\r
952 twoPassEncoding = ""
\r
955 If (deinterlace = 1) Then
\r
956 deinterlace = " -d "
\r
961 If (grayscale = 1) Then
\r
967 If (videoFramerate = "Automatic") Then
\r
968 videoFramerate = ""
\r
970 videoFramerate = " -r " + videoFramerate
\r
973 If (pixelRatio = 1) Then
\r
974 pixelRatio = " -p "
\r
979 If (ChapterMarkers = 1) Then
\r
980 ChapterMarkers = " -m "
\r
982 ChapterMarkers = ""
\r
986 Dim queryVideoSettings As String = videoBitrate + videoFilesize + videoQuality + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers
\r
987 '----------------------------------------------------------------------
\r
989 'Audio Settings Tab
\r
990 Dim audioBitrate As String = drp_audioBitrate.Text
\r
991 Dim audioSampleRate As String = drp_audioSampleRate.Text
\r
992 Dim audioChannels As String = drp_audioChannels.Text
\r
993 Dim SixChannelAudio As String = Check6ChanAudio.CheckState
\r
995 If (audioBitrate <> "") Then
\r
996 audioBitrate = " -B " + audioBitrate
\r
999 If (audioSampleRate <> "") Then
\r
1000 audioSampleRate = " -R " + audioSampleRate
\r
1004 If (audioChannels = "Automatic") Then
\r
1005 audioChannels = ""
\r
1006 ElseIf (audioChannels = "") Then
\r
1007 audioChannels = ""
\r
1009 Dim tempSub() As String
\r
1010 tempSub = audioChannels.Split(" ")
\r
1011 audioChannels = " -a " + tempSub(0)
\r
1014 If (SixChannelAudio = 1) Then
\r
1015 If (drp_audioMixDown.Text = "Automatic") Then
\r
1016 drp_audioMixDown.Text = ""
\r
1018 Dim Mixdown As String = drp_audioMixDown.Text
\r
1019 If Mixdown = "Mono" Then
\r
1021 ElseIf Mixdown = "Stereo" Then
\r
1022 Mixdown = "stereo"
\r
1023 ElseIf Mixdown = "Dolby Surround" Then
\r
1025 ElseIf Mixdown = "Dolby Pro Logic II" Then
\r
1027 ElseIf Mixdown = "6 Channel Discrete" Then
\r
1032 SixChannelAudio = " -6 " & Mixdown
\r
1034 SixChannelAudio = ""
\r
1037 Dim queryAudioSettings As String = audioBitrate + audioSampleRate + audioChannels + SixChannelAudio
\r
1038 '----------------------------------------------------------------------
\r
1042 Dim CRF As String = CheckCRF.CheckState
\r
1043 Dim h264Advanced = rtf_h264advanced.Text
\r
1051 If (h264Advanced = "") Then
\r
1054 h264Advanced = " -x " + h264Advanced
\r
1057 Dim h264Settings As String = CRF + h264Advanced
\r
1058 '----------------------------------------------------------------------
\r
1060 'Advanced Settings Tab
\r
1061 Dim processors As String = drp_processors.Text
\r
1063 ' Number of Processors Handler
\r
1064 If (processors = "Automatic") Then
\r
1067 processors = " -C " + processors + " "
\r
1070 Dim queryAdvancedSettings As String = processors
\r
1071 '----------------------------------------------------------------------
\r
1073 Return querySource + queryDestination + queryPictureSettings + queryVideoSettings + h264Settings + queryAudioSettings + queryAdvancedSettings
\r
1080 '# hbcli.exe Handling. Some clever multi-threaded code to monitor the encode process.
\r
1084 ' Lets watch the hbcli process and when it finishes then Raise Event ThreadComplete
\r
1085 Dim WithEvents hbcliMonitor As ProcessMonitor
\r
1086 Public Class ProcessMonitor
\r
1087 Public isRunning As Integer = 1
\r
1089 Public Event ThreadComplete(ByVal isRunning As Integer)
\r
1091 Public Sub tmrProcCheck()
\r
1092 Dim isRunning As Integer
\r
1093 Dim process2 As Process = New Process
\r
1094 Dim running As Boolean = True
\r
1095 Dim hbProcess As Process() = Process.GetProcesses()
\r
1098 Thread.Sleep(1000)
\r
1099 hbProcess = Process.GetProcesses()
\r
1101 Dim processArr2 As Process() = hbProcess
\r
1102 Dim i As Integer = 0
\r
1103 While i < CInt(processArr2.Length)
\r
1104 Dim process1 As Process = processArr2(i)
\r
1105 If process1.ProcessName.Equals("hbcli") Then
\r
1112 RaiseEvent ThreadComplete(isRunning)
\r
1116 ' The hbcli processes has exited at this point. Lets throw a messagebox at the user telling him the enocode has completed.
\r
1117 Sub TheadCompletedMonitor(ByVal isRunning As Integer) Handles hbcliMonitor.ThreadComplete
\r
1118 Dim ApplicationPath As String = Application.StartupPath ' The applications start parth
\r
1119 MessageBox.Show("Status: The encoding process has ended.")
\r
1121 '------------------------------------------------
\r