Sign in to follow this  
Followers 0
lokster

viDrop

5 posts in this topic

Recently I bought a cheap, but useful 1Gig handheld MP4 player. It can play XVID encoded AVI files at resolution 320x240.

Digging in the web, I realized that there are a lot of players, branded differently around the world, based on the same same hardware. They even look the same (or almost the same).

The chipset manufacturer is RockChip. If your MP4 Player is detected as "RockChip...bla..bla..device" the chances are good that this video converter is for you.

It is just a frontend to mencoder. And it can embed subtitles in the movie, so you can watch movies with subtitles.

You can download the installer from http://lokiisyourmaster.googlepages.com/vi...0.3-install.exe. (7M, because of mplayer+mencoder)

It contains everything needed. +Source code.

Screenshots:

Posted Image Posted Image

And this is how my player looks like:

Posted Image

Don't know if this will be useful to anyone, but here it is...

The .au3 script:

CODE
#NoTrayIcon

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_icon=applications-multimedia.ico

#AutoIt3Wrapper_Compression=4

#AutoIt3Wrapper_Allow_Decompile=n

#AutoIt3Wrapper_Res_Comment=This will help you convert different kinds of video files to format compatible with the RockChip based MP4 players sold around the globe

#AutoIt3Wrapper_Res_LegalCopyright=lokster

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstants.au3>

#include <Constants.au3>

#include <File.au3>

#Include <misc.au3>

#Include <GuiSlider.au3>

#Include <GuiCombo.au3>

Opt("TrayAutoPause", 0)

Opt("GUIOnEventMode", 1)

Global $APPTITLE = 'viDrop'

Global $APPVERSION = 'version 0.3 (20070814)'

Global $CREDIT = 'created by lokster'

#Region ### START Koda GUI section ### Form=AForm1.kxf

Global $AForm1 = GUICreate($APPTITLE & " " & $APPVERSION, 331, 412, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE))

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

Global $Tab1 = GUICtrlCreateTab(0, 24, 329, 386, $TCS_HOTTRACK)

GUICtrlSetResizing($Tab1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

Global $TabSheet1 = GUICtrlCreateTabItem("Main")

Global $Button4 = GUICtrlCreateButton("Add", 4, 232, 59, 25, 0)

GUICtrlSetOnEvent($Button4, "Button4Click")

GUICtrlSetTip($Button4, "Add to batch")

Global $Button5 = GUICtrlCreateButton("Run batch", 135, 232, 57, 25, 0)

GUICtrlSetOnEvent($Button5, "Button5Click")

GUICtrlSetTip($Button5, "Execute batch")

Global $Edit1 = GUICtrlCreateEdit("", 4, 263, 321, 142)

GUICtrlSetFont($Edit1, 10, 400, 0, "Fixedsys")

GUICtrlSetTip($Edit1, "Current batch jobs")

Global $Button6 = GUICtrlCreateButton("Clear", 69, 232, 59, 25, 0)

GUICtrlSetOnEvent($Button6, "Button6Click")

GUICtrlSetTip($Button6, "Clear batch")

Global $Group4 = GUICtrlCreateGroup("Input video", 4, 50, 321, 64, $BS_CENTER)

Global $Input1 = GUICtrlCreateInput("", 12, 66, 252, 21)

GUICtrlSetBkColor($Input1, 0x00FF00)

GUICtrlSetTip($Input1, "Drag & Drop input videos here")

Global $Button1 = GUICtrlCreateButton("...", 269, 66, 21, 21, 0)

GUICtrlSetOnEvent($Button1, "Button1Click")

GUICtrlSetTip($Button1, "Select input video file")

Global $Button8 = GUICtrlCreateButton("i", 296, 66, 21, 21, 0)

GUICtrlSetOnEvent($Button8, "Button8Click")

GUICtrlSetTip($Button8, "View info about the input video file")

Global $Checkbox2 = GUICtrlCreateCheckbox("Auto add to batch", 12, 90, 273, 17)

GUICtrlSetState($Checkbox2, $GUI_CHECKED)

GUICtrlSetTip($Checkbox2, "Automatically add file to batch on open (usefull if you process many files with the same settings)")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Group5 = GUICtrlCreateGroup("Output video", 4, 162, 321, 64, $BS_CENTER)

Global $Input3 = GUICtrlCreateInput("", 12, 178, 278, 21)

GUICtrlSetTip($Input3, "Output video file")

Global $Button3 = GUICtrlCreateButton("...", 296, 178, 21, 21, 0)

GUICtrlSetOnEvent($Button3, "Button3Click")

GUICtrlSetTip($Button3, "Select output video file")

Global $Checkbox1 = GUICtrlCreateCheckbox("Rebuild index", 12, 202, 277, 17)

GUICtrlSetTip($Checkbox1, "Force rebuild of the AVI Index")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Button9 = GUICtrlCreateButton("Run", 265, 232, 59, 25, $BS_CENTER)

GUICtrlSetOnEvent($Button9, "Button9Click")

GUICtrlSetTip($Button9, "Start the conversion")

Global $Button10 = GUICtrlCreateButton("Preview", 200, 232, 59, 25, 0)

GUICtrlSetOnEvent($Button10, "Button10Click")

GUICtrlSetTip($Button10, "Preview 15 seconds of the resulting video")

Global $Group8 = GUICtrlCreateGroup("Input subtitle", 4, 114, 321, 46, $BS_CENTER)

Global $Input2 = GUICtrlCreateInput("", 12, 130, 278, 21)

GUICtrlSetTip($Input2, "Input subtitle file")

Global $Button2 = GUICtrlCreateButton("...", 296, 130, 21, 21, 0)

GUICtrlSetOnEvent($Button2, "Button2Click")

GUICtrlSetTip($Button2, "Select input subtitle file")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $TabSheet2 = GUICtrlCreateTabItem("Settings")

Global $Group1 = GUICtrlCreateGroup("Video", 4, 50, 217, 141, $BS_CENTER)

Global $Label15 = GUICtrlCreateLabel("Codec", 12, 66, 38, 14)

Global $Combo2 = GUICtrlCreateCombo("", 12, 82, 58, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))

GUICtrlSetData($Combo2, "xvid|copy")

GUICtrlSetOnEvent($Combo2, "Combo2Change")

GUICtrlSetTip($Combo2, "Select output video codec")

Global $Label4 = GUICtrlCreateLabel("Bitrate", 12, 106, 151, 13)

GUICtrlSetTip($Label4, "Output video bitrate")

Global $Label5 = GUICtrlCreateLabel("1000", 172, 122, 41, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)

GUICtrlSetTip($Label5, "Output video bitrate")

Global $Slider1 = GUICtrlCreateSlider(12, 122, 154, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)

GUICtrlSetLimit($Slider1, 3200, 0)

GUICtrlSetData($Slider1, 400)

GUICtrlSetTip($Slider1, "Set output video bitrate")

Global $Label10 = GUICtrlCreateLabel("Motion search precision", 12, 146, 154, 13)

GUICtrlSetTip($Label10, "Motion estimation precision")

Global $Label11 = GUICtrlCreateLabel("0", 172, 162, 41, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)

GUICtrlSetTip($Label11, "Motion estimation precision")

Global $Slider3 = GUICtrlCreateSlider(12, 162, 154, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)

GUICtrlSetLimit($Slider3, 6, 0)

GUICtrlSetTip($Slider3, "Motion estimation precision")

Global $Input4 = GUICtrlCreateInput("", 76, 82, 43, 21)

GUICtrlSetTip($Input4, "Output video width")

Global $Label8 = GUICtrlCreateLabel("Width", 76, 66, 32, 13)

Global $Input5 = GUICtrlCreateInput("", 124, 82, 43, 21)

GUICtrlSetTip($Input5, "Output video height")

Global $Label9 = GUICtrlCreateLabel("Height", 124, 66, 35, 13)

Global $Label13 = GUICtrlCreateLabel("FPS", 172, 66, 24, 13)

Global $Input11 = GUICtrlCreateInput("", 172, 82, 43, 21)

GUICtrlSetTip($Input11, "Frames Per Second of the output movie. If 0, uses the input movie FPS.")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Group2 = GUICtrlCreateGroup("Audio", 4, 193, 321, 61, $BS_CENTER)

Global $Combo3 = GUICtrlCreateCombo("", 12, 225, 50, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))

GUICtrlSetData($Combo3, "copy|mp2|nosound")

GUICtrlSetOnEvent($Combo3, "Combo3Change")

GUICtrlSetTip($Combo3, "Output audio codec")

Global $Label16 = GUICtrlCreateLabel("Codec", 12, 209, 38, 13)

Global $Label6 = GUICtrlCreateLabel("Bitrate", 140, 209, 31, 13)

GUICtrlSetTip($Label6, "Output Audio bitrate")

Global $Label7 = GUICtrlCreateLabel("0", 196, 225, 34, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)

GUICtrlSetTip($Label7, "Output Audio bitrate")

Global $Slider2 = GUICtrlCreateSlider(140, 225, 50, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)

GUICtrlSetLimit($Slider2, 20, 1)

GUICtrlSetData($Slider2, 1)

GUICtrlSetTip($Slider2, "Set output Audio bitrate")

Global $Combo1 = GUICtrlCreateCombo("", 68, 225, 66, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))

GUICtrlSetData($Combo1, "16000|22050|24000|32000|44100|48000")

GUICtrlSetTip($Combo1, "Audio sampling rate")

Global $Label14 = GUICtrlCreateLabel("Sample Rate", 68, 209, 63, 13)

Global $Checkbox3 = GUICtrlCreateCheckbox("Normalize", 236, 208, 65, 17)

Global $Checkbox4 = GUICtrlCreateCheckbox("Extra stereo", 236, 231, 81, 17)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Group3 = GUICtrlCreateGroup("Subtitles", 4, 256, 321, 102, $BS_CENTER)

Global $Input6 = GUICtrlCreateInput("", 12, 328, 49, 21)

GUICtrlSetTip($Input6, "Subtitle text codepage")

Global $Label17 = GUICtrlCreateLabel("Codepage", 12, 312, 56, 13)

Global $Input7 = GUICtrlCreateInput("", 12, 288, 274, 21)

GUICtrlSetTip($Input7, "Subtitle font")

Global $Button7 = GUICtrlCreateButton("...", 292, 288, 21, 21, 0)

GUICtrlSetOnEvent($Button7, "Button7Click")

GUICtrlSetTip($Button7, "Select subtitle font")

Global $Label12 = GUICtrlCreateLabel("Font", 12, 272, 25, 13)

Global $Label18 = GUICtrlCreateLabel("VPos, %", 68, 312, 46, 13)

Global $Input8 = GUICtrlCreateInput("", 68, 328, 49, 21)

GUICtrlSetTip($Input8, "Vertical position of the subtitles")

Global $Input9 = GUICtrlCreateInput("", 124, 328, 49, 21)

GUICtrlSetTip($Input9, "Maximum width of one subtitle line")

Global $Label19 = GUICtrlCreateLabel("Max Width, %", 124, 312, 69, 14)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Group6 = GUICtrlCreateGroup("Additional command line parameters", 4, 358, 321, 45, $BS_CENTER)

Global $Input10 = GUICtrlCreateInput("", 12, 374, 305, 21)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $Group7 = GUICtrlCreateGroup("Resize method", 228, 50, 97, 77, $BS_CENTER)

Global $Radio1 = GUICtrlCreateRadio("Pan&&Scan", 236, 74, 73, 17)

GUICtrlSetState($Radio1, $GUI_CHECKED)

GUICtrlSetTip($Radio1, "Resize and crop the video so that entire screen is filled")

Global $Radio2 = GUICtrlCreateRadio("Keep aspect", 236, 90, 81, 17)

GUICtrlSetTip($Radio2, "Resize to the specified width, height is calculated so that the original aspect ratio is kept")

Global $Radio3 = GUICtrlCreateRadio("Letterbox", 236, 106, 81, 17)

GUICtrlSetTip($Radio3, "Resize to the specified width and height, adding black bars top and bottom to preserve aspect ratio if necessary")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $TabSheet3 = GUICtrlCreateTabItem("About")

Global $Label20 = GUICtrlCreateLabel($APPTITLE, 4, 50, 321, 81, BitOR($SS_CENTER, $SS_CENTERIMAGE))

GUICtrlSetFont($Label20, 24, 800, 0, "MS Sans Serif")

Global $Label21 = GUICtrlCreateLabel($APPVERSION, 4, 131, 321, 17, $SS_CENTER)

Global $Label22 = GUICtrlCreateLabel($CREDIT, 4, 148, 321, 60, $SS_CENTER)

GUICtrlSetFont($Label22, 14, 400, 4, "MS Sans Serif")

GUICtrlSetColor($Label22, 0x0000FF)

GUICtrlSetOnEvent($Label22, "Label22Click")

GUICtrlSetCursor($Label22, 0)

Global $Edit2 = GUICtrlCreateEdit("", 4, 208, 321, 198, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))

GUICtrlSetData($Edit2, StringFormat($APPTITLE & " uses mplayer and mencoder - http://www.mplayerhq.hu/\r\nAlso, the DejaVu Sans font - http://sourceforge.net/projects/dejavu ...;r\n" & $APPTITLE & " is written in the free scripting language AutoIt - \r\nhttp://www.autoitscript.com/\r\nThe viDrop.au3 file in the main directory contains the source code.\r\nThe AForm1.kxf is the GUI file for Koda Form Designer for AutoIt.\r\n\r\n" & $APPTITLE & " is distributed under the terms of GPL version 3 license. \r\nSee the gpl-3.0.txt file in the " & $APPTITLE & " directory for any details.\r\n"))

GUICtrlCreateTabItem("")

Global $Combo4 = GUICtrlCreateCombo("", 38, 0, 208, 25)

GUICtrlSetOnEvent($Combo4, "Combo4Change")

Global $Label23 = GUICtrlCreateLabel("Preset:", 3, 3, 34, 17)

Global $Button11 = GUICtrlCreateButton("Del", 294, 0, 35, 21, 0)

GUICtrlSetOnEvent($Button11, "Button11Click")

GUICtrlSetTip($Button11, "Add to batch")

Global $Button12 = GUICtrlCreateButton("Save", 252, 0, 35, 21, 0)

GUICtrlSetOnEvent($Button12, "Button12Click")

GUICtrlSetTip($Button12, "Add to batch")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Global $WM_DROPFILES = 0x233

Global Const $TBM_SETTIPSIDE = $WM_USER + 31

Global Const $WM_HSCROLL = 0x0114

Global $gaDropFiles[1], $str = ""

Global $vidinfo[11]

GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")

GUISetOnEvent($GUI_EVENT_DROPPED, "SpecialEvents")

GUICtrlSetState($Input1, $GUI_DROPACCEPTED)

GUIRegisterMsg($WM_HSCROLL, "trackbar_change")

GUICtrlSetData($Label5, GUICtrlRead($Slider1))

GUICtrlSetData($Label7, GUICtrlRead($Slider2) * 16)

GUICtrlSetData($Label11, GUICtrlRead($Slider3))

_SendMessage(GUICtrlGetHandle($Slider1), $TBM_SETTICFREQ, 128, 0)

_SendMessage(GUICtrlGetHandle($Slider2), $TBM_SETTICFREQ, 1, 0)

_SendMessage(GUICtrlGetHandle($Slider3), $TBM_SETTICFREQ, 1, 0)

GUISetState(@SW_SHOW)

LoadSettings(@ScriptDir & '\' & $APPTITLE & '.ini')

ListPresets()

;LoadLocale(@ScriptDir&'\bg.ini')

If UBound($CmdLine) > 1 Then

If UBound($CmdLine) > 2 Then

For $i = 0 To UBound($CmdLine) - 1

OpenFile($CmdLine[$i])

Next

Else

OpenFile($CmdLine[1])

EndIf

EndIf

While 1

Sleep(100)

WEnd

Func ListPresets()

GUICtrlSetData($Combo4, "||")

Local $search = FileFindFirstFile(@ScriptDir & "\presets\*.ini")

If $search = -1 Then Return

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

GUICtrlSetData($Combo4, $file & "|")

WEnd

FileClose($search)

EndFunc ;==>ListPresets

Func Combo4Change()

If FileExists(@ScriptDir & "\presets\" & GUICtrlRead($Combo4)) Then

LoadSettings(@ScriptDir & "\presets\" & GUICtrlRead($Combo4))

EndIf

EndFunc ;==>Combo4Change

Func SaveSettings($file)

IniWrite($file, 'settings', 'RebuildIndex', Number(GUICtrlRead($Checkbox1) == $GUI_CHECKED))

IniWrite($file, 'settings', 'AutoAddOnOpen', Number(GUICtrlRead($Checkbox2) == $GUI_CHECKED))

IniWrite($file, 'settings', 'Normalize', Number(GUICtrlRead($Checkbox3) == $GUI_CHECKED))

IniWrite($file, 'settings', 'ExtraStereo', Number(GUICtrlRead($Checkbox4) == $GUI_CHECKED))

IniWrite($file, 'settings', 'SRate', GUICtrlRead($Combo1))

IniWrite($file, 'settings', 'VideoCodec', GUICtrlRead($Combo2))

IniWrite($file, 'settings', 'AudioCodec', GUICtrlRead($Combo3))

IniWrite($file, 'settings', 'VideoBitrate', GUICtrlRead($Slider1))

IniWrite($file, 'settings', 'AudioBitrate', GUICtrlRead($Slider2))

IniWrite($file, 'settings', 'MotionEst', GUICtrlRead($Slider3))

IniWrite($file, 'settings', 'Width', GUICtrlRead($Input4))

IniWrite($file, 'settings', 'Height', GUICtrlRead($Input5))

IniWrite($file, 'settings', 'SubFont', GUICtrlRead($Input7))

IniWrite($file, 'settings', 'SubCP', GUICtrlRead($Input6))

IniWrite($file, 'settings', 'SupPos', GUICtrlRead($Input8))

IniWrite($file, 'settings', 'SubWidth', GUICtrlRead($Input9))

IniWrite($file, 'settings', 'CmdLine', GUICtrlRead($Input10))

IniWrite($file, 'settings', 'FPS', GUICtrlRead($Input11))

If GUICtrlRead($Radio1) == $GUI_CHECKED Then

IniWrite($file, 'settings', 'ResizeMethod', 1)

ElseIf GUICtrlRead($Radio2) == $GUI_CHECKED Then

IniWrite($file, 'settings', 'ResizeMethod', 2)

ElseIf GUICtrlRead($Radio3) == $GUI_CHECKED Then

IniWrite($file, 'settings', 'ResizeMethod', 3)

EndIf

EndFunc ;==>SaveSettings

Func LoadSettings($file = "")

If IniRead($file, 'settings', 'RebuildIndex', 0) == 1 Then

GUICtrlSetState($Checkbox1, $GUI_CHECKED)

Else

GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)

EndIf

If IniRead($file, 'settings', 'AutoAddOnOpen', 0) == 1 Then

GUICtrlSetState($Checkbox2, $GUI_CHECKED)

Else

GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)

EndIf

If IniRead($file, 'settings', 'Normalize', 1) == 1 Then

GUICtrlSetState($Checkbox3, $GUI_CHECKED)

Else

GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)

EndIf

If IniRead($file, 'settings', 'ExtraStereo', 0) == 1 Then

GUICtrlSetState($Checkbox4, $GUI_CHECKED)

Else

GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)

EndIf

_GUICtrlComboSelectString($Combo1, -1, IniRead($file, 'settings', 'SRate', 44100))

_GUICtrlComboSelectString($Combo2, -1, IniRead($file, 'settings', 'VideoCodec', 'xvid'))

_GUICtrlComboSelectString($Combo3, -1, IniRead($file, 'settings', 'AudioCodec', 'mp2'))

GUICtrlSetData($Slider1, IniRead($file, 'settings', 'VideoBitrate', 400))

GUICtrlSetData($Slider2, IniRead($file, 'settings', 'AudioBitrate', 8))

GUICtrlSetData($Slider3, IniRead($file, 'settings', 'MotionEst', 4))

GUICtrlSetData($Input4, IniRead($file, 'settings', 'Width', 320))

GUICtrlSetData($Input5, IniRead($file, 'settings', 'Height', 240))

GUICtrlSetData($Input6, IniRead($file, 'settings', 'SubCP', 'cp1251'))

GUICtrlSetData($Input7, IniRead($file, 'settings', 'SubFont', '.\mplayer\subfont.ttf'))

GUICtrlSetData($Input8, IniRead($file, 'settings', 'SupPos', 100))

GUICtrlSetData($Input9, IniRead($file, 'settings', 'SubWidth', 100))

GUICtrlSetData($Input10, IniRead($file, 'settings', 'CmdLine', ''))

GUICtrlSetData($Input11, IniRead($file, 'settings', 'FPS', '22'))

GUICtrlSetData($Label5, GUICtrlRead($Slider1))

GUICtrlSetData($Label7, GUICtrlRead($Slider2) * 16)

GUICtrlSetData($Label11, GUICtrlRead($Slider3))

Switch IniRead($file, 'settings', 'ResizeMethod', '1')

Case 1

GUICtrlSetState($Radio1, $GUI_CHECKED)

Case 2

GUICtrlSetState($Radio2, $GUI_CHECKED)

Case 3

GUICtrlSetState($Radio3, $GUI_CHECKED)

EndSwitch

Combo2Change()

Combo3Change()

CalcOutputSize()

EndFunc ;==>LoadSettings

Func CalcOutputSize()

WinSetTitle($AForm1, "", $APPTITLE & ' (Output: ~' & Round($vidinfo[10] * (GUICtrlRead($Slider1) + GUICtrlRead($Slider2) * 16) / 8 / 1024, 2) & ' MB)')

EndFunc ;==>CalcOutputSize

Func trackbar_change($hWnd, $Msg, $wParam, $lParam)

Switch $lParam

Case GUICtrlGetHandle($Slider1)

GUICtrlSetData($Label5, GUICtrlRead($Slider1))

CalcOutputSize()

Case GUICtrlGetHandle($Slider2)

GUICtrlSetData($Label7, GUICtrlRead($Slider2) * 16)

CalcOutputSize()

Case GUICtrlGetHandle($Slider3)

GUICtrlSetData($Label11, GUICtrlRead($Slider3))

EndSwitch

EndFunc ;==>trackbar_change

Func getVidInfo($file)

Global $vidinfo[11]

$cmd = '"' & @ScriptDir & '\mplayer.exe" -slave -identify -quiet -frames 0 -vo null -ao null "' & $file & '"'

SplashTextOn("", "Loading, please wait...", 320, 32, -1, -1, 1 + 32, "", 16, 1000)

$pid = Run($cmd, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)

$text = ""

While ProcessExists($pid)

$text &= StdoutRead($pid)

WEnd

SplashOff()

$out = StringSplit($text, @CRLF, 1)

$count = $out[0]

For $i = 1 To $count

$line = $out[$i]

$str = StringRegExp($line, '^([a-zA-Z_].*)=(.*?)$', 1)

If @error = 0 Then

Switch $str[0]

Case 'ID_DEMUXER'

$vidinfo[0] = $str[1]

Case 'ID_VIDEO_FORMAT'

$vidinfo[1] = $str[1]

Case 'ID_VIDEO_BITRATE'

$vidinfo[2] = $str[1]

Case 'ID_VIDEO_WIDTH'

$vidinfo[3] = $str[1]

Case 'ID_VIDEO_HEIGHT'

$vidinfo[4] = $str[1]

Case 'ID_VIDEO_FPS'

$vidinfo[5] = $str[1]

Case 'ID_AUDIO_CODEC'

$vidinfo[6] = $str[1]

Case 'ID_AUDIO_BITRATE'

$vidinfo[7] = $str[1]

Case 'ID_AUDIO_RATE'

$vidinfo[8] = $str[1]

Case 'ID_AUDIO_NCH'

$vidinfo[9] = $str[1]

Case 'ID_LENGTH'

$vidinfo[10] = $str[1]

EndSwitch

EndIf

Next

EndFunc ;==>getVidInfo

Func Button1Click()

$movie = FileOpenDialog("Select input movie", "", "Multimedia files (*.avi;*.mpg;*.mpeg;*.3gp;*.qt;*.mp1;*.mp2;*.wmv;*.asf;*.asf;*.wav;*.swf;*.flv;*.rm;*.au;*.nut;*.mov

;*.mp4;*.dv)", 1)

If $movie <> '' Then

OpenFile($movie)

EndIf

EndFunc ;==>Button1Click

Func Button2Click()

$isub = FileOpenDialog("Select input subtitle", "", "Subtitles (*.sub;*.txt;*.srt)", 1, GUICtrlRead($Input2))

If $isub <> '' Then

GUICtrlSetData($Input2, $isub)

EndIf

EndFunc ;==>Button2Click

Func Button3Click()

$outf = FileSaveDialog("Select output file", "", "Multimedia files (*.avi;*.mpg;*.asf;*.wav;*.swf;*.flv;*.rm;*.au;*.nut;*.mov;*.mp4;*.dv)", 0, GUICtrlRead($Input3))

If $outf <> '' Then

GUICtrlSetData($Input3, $outf)

EndIf

EndFunc ;==>Button3Click

Func Button4Click()

Local $cmd = GenerateCommandLine()

GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & $cmd & @CRLF)

EndFunc ;==>Button4Click

Func GenerateCommandLine($preview = False, $twopass = False)

Local $sInputVideo = GUICtrlRead($Input1)

Local $sInputSubtitle = GUICtrlRead($Input2)

Local $sOutputVideo = GUICtrlRead($Input3)

Local $iVideoMotionEstimation = GUICtrlRead($Slider3)

Local $iVideoBitrate = GUICtrlRead($Slider1)

Local $iAudioBitrate = GUICtrlRead($Slider2) * 16

Local $iWidth = GUICtrlRead($Input4)

Local $iHeight = GUICtrlRead($Input5)

Local $fZoom = 1

Local $iSRate = GUICtrlRead($Combo1)

Local $sVideoCodec = GUICtrlRead($Combo2)

Local $sAudioCodec = GUICtrlRead($Combo3)

Local $cmd = '"' & @ScriptDir & '\mencoder.exe" "' & $sInputVideo & '" -cache 16384 -idx -noodml -of avi'

If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then ;force rebuild index

$cmd &= ' -forceidx'

EndIf

Switch $sVideoCodec

Case 'copy'

$cmd &= ' -ovc copy'

Case 'xvid'

$cmd &= ' -ovc xvid -xvidencopts bitrate=' & $iVideoBitrate & ':max_bframes=0:quant_type=h263:me_quality=' & $iVideoMotionEstimation

$cmd &= ':turbo:nochroma_me:notrellis:vhq=0'

If GUICtrlRead($Radio1) == $GUI_CHECKED Then

$cmd &= ' -vf-add scale=-2:' & $iHeight & ',crop=' & $iWidth & ':' & $iHeight

ElseIf GUICtrlRead($Radio2) == $GUI_CHECKED Then

$cmd &= ' -vf-add scale=' & $iWidth & ':-2'

ElseIf GUICtrlRead($Radio3) == $GUI_CHECKED Then

$cmd &= ' -vf-add scale=' & $iWidth & ':-2,expand=:::::' & $iWidth & '/' & $iHeight

EndIf

If FileExists($sInputSubtitle) Then

$cmd &= ' -sub "' & $sInputSubtitle & '" -subcp ' & GUICtrlRead($Input6) & ' -font "' & GUICtrlRead($Input7) & '" -subpos ' & GUICtrlRead($Input8) & ' -subwidth ' & GUICtrlRead($Input9) & ' -subfont-text-scale 5'

Else

$cmd &= ''

EndIf

EndSwitch

If GUICtrlRead($Input11) > 0 Then

$cmd &= ' -ofps ' & GUICtrlRead($Input11)

EndIf

Switch $sAudioCodec

Case 'copy'

$cmd &= ' -oac copy'

Case 'mp2'

$cmd &= ' -oac lavc -lavcopts acodec=mp2:abitrate=' & $iAudioBitrate & ' -srate ' & $iSRate

If GUICtrlRead($Checkbox3) == $GUI_CHECKED Then

$cmd &= ' -af volnorm'

EndIf

If GUICtrlRead($Checkbox4) == $GUI_CHECKED Then

$cmd &= ' -af extrastereo=2.5'

EndIf

Case 'nosound'

$cmd &= ' -nosound'

EndSwitch

If $preview Then

$cmd &= ' -ss ' & Round(Random(0, $vidinfo[10])) & ' -endpos 15 -o "' & @TempDir & '\preview.avi" '

Else

$cmd &= ' -o "' & $sOutputVideo & '" '

EndIf

$cmd &= GUICtrlRead($Input10)

$cmd &= ' -vf-add harddup '

Return $cmd

EndFunc ;==>GenerateCommandLine

Func Button7Click()

Local $pos = WinGetPos($AForm1)

If $pos[2] == 236 Then

WinMove($AForm1, "", Default, Default, 500, Default)

Else

WinMove($AForm1, "", Default, Default, 236, Default)

EndIf

EndFunc ;==>Button7Click

Func Button5Click()

$batch = GUICtrlRead($Edit1)

$batch = StringStripCR($batch)

$batch = StringSplit($batch, @LF)

GUISetState(@SW_HIDE)

Opt("TrayIconHide", 0)

Opt("TrayAutoPause", 0)

For $i = 1 To UBound($batch) - 1

If $batch[$i] <> "" Then

$text = "Converting file " & $i & " of " & UBound($batch) - 2

TraySetToolTip($text)

TrayTip("Running batch convert", $text, 10, 1 + 16)

RunWait($batch[$i], @ScriptDir, @SW_SHOW)

EndIf

Next

TraySetToolTip()

Opt("TrayIconHide", 1)

GUISetState(@SW_SHOW)

EndFunc ;==>Button5Click

Func Button6Click()

If MsgBox(32 + 4, "Confirm", "Delete batch?") == 6 Then

GUICtrlSetData($Edit1, "")

EndIf

EndFunc ;==>Button6Click

Func Button8Click()

$tip = "------------------------------------------------" & @CRLF

$tip &= "Movie Length: " & $vidinfo[10] & " sec" & @CRLF

$tip &= "FPS: " & $vidinfo[5] & @CRLF

$tip &= "Width: " & $vidinfo[3] & @CRLF

$tip &= "Height: " & $vidinfo[4] & @CRLF

$tip &= "Video bitrate: " & $vidinfo[2] / 1000 & " kbit/s" & @CRLF

$tip &= "Audiobitrate: " & $vidinfo[7] / 1000 & " kbit/s" & @CRLF

$tip &= "Video codec: " & $vidinfo[1] & @CRLF

$tip &= "Audio codec: " & $vidinfo[6] & @CRLF

$tip &= "Audio nCh.: " & $vidinfo[9]

$tip &= @CRLF & "------------------------------------------------"

MsgBox(0, "Input file info:", $tip)

EndFunc ;==>Button8Click

Func Button9Click()

Local $cmd = GenerateCommandLine()

GUISetState(@SW_HIDE)

RunWait($cmd, @ScriptDir, @SW_SHOW)

GUISetState(@SW_SHOW)

EndFunc ;==>Button9Click

Func Button10Click()

Local $cmd = GenerateCommandLine(True)

GUISetState(@SW_HIDE)

RunWait($cmd, @ScriptDir, @SW_SHOW)

RunWait('"' & @ScriptDir & '\mplayer.exe" "' & @TempDir & '\preview.avi' & '"', @ScriptDir)

GUISetState(@SW_SHOW)

EndFunc ;==>Button10Click

Func Button11Click()

;~ Local $from = FileOpenDialog("Load config from...", @ScriptDir & "\presets", "Config files (*.ini)")

;~

;~ If $from <> '' Then

;~ LoadSettings($from)

;~ EndIf

If MsgBox(4 + 32, "Confirm", "Are you sure you want to delete this preset?") == 6 Then

FileDelete(@ScriptDir & "\presets\" & GUICtrlRead($Combo4))

ListPresets()

LoadSettings()

EndIf

EndFunc ;==>Button11Click

Func Button12Click()

;Local $target = FileSaveDialog("Save config to...", "", "Config files (*.ini)", 16)

Local $target = GUICtrlRead($Combo4)

Local $file = @ScriptDir & "\presets\" & $target

If $target <> '' Then

If StringInStr($file, '.ini') = 0 Then

$file &= '.ini'

EndIf

SaveSettings($file)

ListPresets()

_GUICtrlComboSelectString($Combo4, -1, $target)

EndIf

EndFunc ;==>Button12Click

Func Combo2Change()

Switch GUICtrlRead($Combo2)

Case 'copy'

GUICtrlSetState($Label4, $GUI_DISABLE)

GUICtrlSetState($Label5, $GUI_DISABLE)

GUICtrlSetState($Label8, $GUI_DISABLE)

GUICtrlSetState($Label9, $GUI_DISABLE)

GUICtrlSetState($Label10, $GUI_DISABLE)

GUICtrlSetState($Label11, $GUI_DISABLE)

GUICtrlSetState($Label13, $GUI_DISABLE)

GUICtrlSetState($Input4, $GUI_DISABLE)

GUICtrlSetState($Input5, $GUI_DISABLE)

GUICtrlSetState($Input11, $GUI_DISABLE)

GUICtrlSetState($Slider1, $GUI_DISABLE)

GUICtrlSetState($Slider3, $GUI_DISABLE)

GUICtrlSetState($Radio1, $GUI_DISABLE)

GUICtrlSetState($Radio2, $GUI_DISABLE)

GUICtrlSetState($Radio3, $GUI_DISABLE)

Case 'xvid'

GUICtrlSetState($Label4, $GUI_ENABLE)

GUICtrlSetState($Label5, $GUI_ENABLE)

GUICtrlSetState($Label8, $GUI_ENABLE)

GUICtrlSetState($Label9, $GUI_ENABLE)

GUICtrlSetState($Label10, $GUI_ENABLE)

GUICtrlSetState($Label11, $GUI_ENABLE)

GUICtrlSetState($Label13, $GUI_ENABLE)

GUICtrlSetState($Input4, $GUI_ENABLE)

GUICtrlSetState($Input5, $GUI_ENABLE)

GUICtrlSetState($Input11, $GUI_ENABLE)

GUICtrlSetState($Slider1, $GUI_ENABLE)

GUICtrlSetState($Slider3, $GUI_ENABLE)

GUICtrlSetState($Radio1, $GUI_ENABLE)

GUICtrlSetState($Radio2, $GUI_ENABLE)

GUICtrlSetState($Radio3, $GUI_ENABLE)

EndSwitch

EndFunc ;==>Combo2Change

Func Combo3Change()

Switch GUICtrlRead($Combo3)

Case 'copy', 'nosound'

GUICtrlSetState($Label6, $GUI_DISABLE)

GUICtrlSetState($Label7, $GUI_DISABLE)

GUICtrlSetState($Label14, $GUI_DISABLE)

GUICtrlSetState($Combo1, $GUI_DISABLE)

GUICtrlSetState($Slider2, $GUI_DISABLE)

GUICtrlSetState($Checkbox3, $GUI_DISABLE)

GUICtrlSetState($Checkbox4, $GUI_DISABLE)

Case 'mp2'

GUICtrlSetState($Label6, $GUI_ENABLE)

GUICtrlSetState($Label7, $GUI_ENABLE)

GUICtrlSetState($Label14, $GUI_ENABLE)

GUICtrlSetState($Combo1, $GUI_ENABLE)

GUICtrlSetState($Slider2, $GUI_ENABLE)

GUICtrlSetState($Checkbox3, $GUI_ENABLE)

GUICtrlSetState($Checkbox4, $GUI_ENABLE)

EndSwitch

EndFunc ;==>Combo3Change

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

SaveSettings(@ScriptDir & '\' & $APPTITLE & '.ini')

Exit

Case @GUI_CtrlId = $GUI_EVENT_DROPPED

If UBound($gaDropFiles) > 1 And GUICtrlRead($Checkbox2) == $GUI_CHECKED Then

For $i = 0 To UBound($gaDropFiles) - 1

OpenFile($gaDropFiles[$i])

Next

Else

OpenFile($gaDropFiles[0])

EndIf

EndSelect

EndFunc ;==>SpecialEvents

Func OpenFile($movie)

GUICtrlSetData($Input1, $movie)

Local $szDrive, $szDir, $szFName, $szExt

$path = _PathSplit($movie, $szDrive, $szDir, $szFName, $szExt)

If FileExists($path[1] & $path[2] & $path[3] & '.txt') Then

$isub = $path[1] & $path[2] & $path[3] & '.txt'

ElseIf FileExists($path[1] & $path[2] & $path[3] & '.sub') Then

$isub = $path[1] & $path[2] & $path[3] & '.sub'

ElseIf FileExists($path[1] & $path[2] & $path[3] & '.srt') Then

$isub = $path[1] & $path[2] & $path[3] & '.srt'

Else

$isub = ''

EndIf

$outf = $path[1] & $path[2] & $path[3] & '_converted' & $path[4]

GUICtrlSetData($Input2, $isub)

GUICtrlSetData($Input3, $outf)

getVidInfo($movie)

CalcOutputSize()

If GUICtrlRead($Checkbox2) == $GUI_CHECKED Then

Button4Click()

EndIf

EndFunc ;==>OpenFile

Func WM_DROPFILES($hWnd, $msgID, $wParam, $lParam)

Local $nSize, $pFileName

Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)

For $i = 0 To $nAmt[0] - 1

$nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)

$nSize = $nSize[0] + 1

$pFileName = DllStructCreate("char[" & $nSize & "]")

DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)

ReDim $gaDropFiles[$i + 1]

$gaDropFiles[$i] = DllStructGetData($pFileName, 1)

$pFileName = 0

Next

EndFunc ;==>WM_DROPFILES

Func OnAutoItExit()

FileDelete(@TempDir & '\preview.avi')

EndFunc ;==>OnAutoItExit

Func LoadLocale($file)

Local $data = IniReadSection($file, 'translation')

For $i = 0 To UBound($data) - 1

If IsDeclared($data[$i][0]) Then

GUICtrlSetData(Eval($data[$i][0]), $data[$i][1])

EndIf

Next

EndFunc ;==>LoadLocale

Func Label22Click()

Run(@ComSpec & " /k start mailto:loksterr@gmail.com", "", @SW_HIDE)

EndFunc ;==>Label22Click

Share this post


Link to post
Share on other sites



Looks very interesting! This is what I long time want to do - portable oriented (for PPC in my case) frontend for mencoder, but have not time yet :)

Yeah, for PPC exists at least three or four similar programs, but I'm dislike them all for different cases, almost all (even paid ones) missed some functions or it's UI is quite unconvenient (PocketDivxEncoder is example). Even if I can't use your program directly, this can be good base for further modification. Thanks for sharing!

Share this post


Link to post
Share on other sites

Yeah, I have used PocketDivXEncoder too, and this is why I decided to write my own mencoder frontend... :)

Share this post


Link to post
Share on other sites

I was just putting together some ideas on how to write this very program. I've even downloaded mencoder and ffmpeg to play around with. I was wanting to convert some videos to play on my PocketPC.

Thanks.

Share this post


Link to post
Share on other sites

After a HUGE delay, I finally decided to post the current version of viDrop (0.52). There are a lot of changes and improvements since the previous version that is posted here.

It can be downloaded from: http://users2.titanichost.com/lokster/en/v....52-install.exe (~7MB - the installer is big because includes mencoder and mplayer - even with UPX compression, they are still big...)

Screenhots:

http://images.ubuntufan.multiply.com/image...HprsBcA75XUQ6jg

http://images.ubuntufan.multiply.com/image...tHbF0h%2BVWxKdg

Currently, there is no help file, maybe in the next version there will be one.

Bugs are (definitely) present, so don't hesitate to report them.

Here is the source code, but note that, the script alone won't run properly. You must use the installer - to install mencoder & mplayer, default subtitle font etc.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=applications-multimedia.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Allow_Decompile=n
#AutoIt3Wrapper_Res_Comment=This will help you convert different kinds of video files to format compatible with the RockChip based MP4 players sold around the globe
#AutoIt3Wrapper_Res_Description=XVID convertor for RockChip players
#AutoIt3Wrapper_Res_Fileversion=0.5.2.0
#AutoIt3Wrapper_Res_LegalCopyright=lokster
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    viDrop - frontend for mencoder
    Copyright (C) 2007  lokster - lokiisyourmaster (AT) gmail (DOT) com
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/.
#ce


#include <GUIConstants.au3>
#include <Constants.au3>
#include <File.au3>
#Include <misc.au3>
#Include <GuiSlider.au3>
#Include <GuiCombo.au3>
#include <INet.au3>

Opt("TrayAutoPause", 0)
Opt("GUIOnEventMode", 1)

Global $APPTITLE = 'viDrop'
Global $APPVERSION = '0.52'
Global $APPVERSION_MINOR = '20071011'
Global $CREDIT = '(c) 2007 lokster'
Global $URL = 'http://skss.freehostia.com/'

#Region ### START Koda GUI section ### Form=AForm1.kxf
Global $AForm1 = GUICreate($APPTITLE & " " & $APPVERSION, 474, 485, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
Global $Tab1 = GUICtrlCreateTab(0, 24, 473, 458, $TCS_HOTTRACK)
GUICtrlSetResizing($Tab1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $TabSheet1 = GUICtrlCreateTabItem("Main Settings")
Global $Edit1 = GUICtrlCreateEdit("", 4, 279, 465, 198)
GUICtrlSetFont($Edit1, 10, 400, 0, "Fixedsys")
Global $Group4 = GUICtrlCreateGroup("Input A/V File", 4, 50, 465, 64, $BS_CENTER)
Global $Input1 = GUICtrlCreateInput("", 12, 66, 396, 21)
GUICtrlSetBkColor($Input1, 0x00FF00)
GUICtrlSetOnEvent($Input1, "Input1Change")
Global $Button1 = GUICtrlCreateButton("...", 413, 66, 21, 21, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
Global $Button8 = GUICtrlCreateButton("i", 440, 66, 21, 21, 0)
GUICtrlSetOnEvent($Button8, "Button8Click")
Global $Checkbox2 = GUICtrlCreateCheckbox("Auto add to batch", 12, 90, 273, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group5 = GUICtrlCreateGroup("Output A/V File", 4, 162, 465, 64, $BS_CENTER)
Global $Input3 = GUICtrlCreateInput("", 12, 178, 422, 21)
Global $Button3 = GUICtrlCreateButton("...", 440, 178, 21, 21, 0)
GUICtrlSetOnEvent($Button3, "Button3Click")
Global $Checkbox1 = GUICtrlCreateCheckbox("Rebuild AVI index", 12, 202, 421, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group8 = GUICtrlCreateGroup("Input subtitle", 4, 114, 465, 46, $BS_CENTER)
Global $Input2 = GUICtrlCreateInput("", 12, 130, 422, 21)
Global $Button2 = GUICtrlCreateButton("...", 440, 130, 21, 21, 0)
GUICtrlSetOnEvent($Button2, "Button2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group9 = GUICtrlCreateGroup("Batch", 4, 226, 273, 49)
Global $Button4 = GUICtrlCreateButton("Add", 12, 242, 83, 25, 0)
GUICtrlSetOnEvent($Button4, "Button4Click")
Global $Button6 = GUICtrlCreateButton("Clear", 100, 242, 83, 25, 0)
GUICtrlSetOnEvent($Button6, "Button6Click")
Global $Button5 = GUICtrlCreateButton("Run", 188, 242, 81, 25, 0)
GUICtrlSetOnEvent($Button5, "Button5Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group10 = GUICtrlCreateGroup("Current file", 284, 226, 185, 49)
Global $Button10 = GUICtrlCreateButton("Preview", 292, 242, 83, 25, 0)
GUICtrlSetOnEvent($Button10, "Button10Click")
Global $Button9 = GUICtrlCreateButton("Convert", 380, 242, 83, 25, $BS_CENTER)
GUICtrlSetOnEvent($Button9, "Button9Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $TabSheet2 = GUICtrlCreateTabItem("Advanced settings")
Global $Group1 = GUICtrlCreateGroup("Video", 4, 50, 257, 101, $BS_CENTER)
Global $Label15 = GUICtrlCreateLabel("Codec", 12, 66, 46, 14)
Global $Combo2 = GUICtrlCreateCombo("", 12, 82, 74, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "xvid|copy")
GUICtrlSetOnEvent($Combo2, "Combo2Change")
Global $Label4 = GUICtrlCreateLabel("Bitrate", 12, 106, 72, 13)
Global $Label5 = GUICtrlCreateLabel("1500", 92, 122, 33, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Slider1 = GUICtrlCreateSlider(12, 122, 74, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider1, 2048, 0)
GUICtrlSetData($Slider1, 400)
Global $Label10 = GUICtrlCreateLabel("Motion search precision", 140, 106, 113, 13)
Global $Label11 = GUICtrlCreateLabel("0", 220, 122, 33, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Slider3 = GUICtrlCreateSlider(140, 122, 74, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider3, 6, 0)
Global $Input4 = GUICtrlCreateInput("", 92, 82, 51, 21)
Global $Label8 = GUICtrlCreateLabel("Width", 92, 66, 43, 14)
Global $Input5 = GUICtrlCreateInput("", 148, 82, 51, 21)
Global $Label9 = GUICtrlCreateLabel("Height", 148, 66, 52, 14)
Global $Label13 = GUICtrlCreateLabel("FPS", 204, 66, 54, 14)
Global $Input11 = GUICtrlCreateInput("", 204, 82, 51, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup("Audio", 4, 154, 257, 101, $BS_CENTER)
Global $Combo3 = GUICtrlCreateCombo("", 12, 186, 58, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo3, "copy|mp2|mp3|nosound")
GUICtrlSetOnEvent($Combo3, "Combo3Change")
Global $Label16 = GUICtrlCreateLabel("Codec", 12, 170, 46, 13)
Global $Label6 = GUICtrlCreateLabel("Bitrate", 148, 170, 61, 13)
Global $Label7 = GUICtrlCreateLabel("0", 220, 186, 34, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Slider2 = GUICtrlCreateSlider(148, 186, 66, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider2, 20, 1)
GUICtrlSetData($Slider2, 1)
Global $Combo1 = GUICtrlCreateCombo("", 76, 186, 66, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "16000|22050|24000|32000|44100|48000")
Global $Label14 = GUICtrlCreateLabel("SRate", 76, 170, 46, 13)
Global $Checkbox3 = GUICtrlCreateCheckbox("Normalize", 12, 210, 65, 15)
GUICtrlSetOnEvent($Checkbox3, "Checkbox3Click")
Global $Checkbox4 = GUICtrlCreateCheckbox("Extra stereo", 148, 209, 81, 17)
Global $Slider9 = GUICtrlCreateSlider(12, 226, 90, 21, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetData($Slider9, 25)
Global $Label33 = GUICtrlCreateLabel("0", 108, 226, 34, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Button15 = GUICtrlCreateButton("<< Default", 148, 228, 67, 17, 0)
GUICtrlSetOnEvent($Button15, "Button15Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("Subtitles", 4, 416, 465, 61, $BS_CENTER)
Global $Input6 = GUICtrlCreateInput("", 252, 448, 65, 21)
Global $Label17 = GUICtrlCreateLabel("Encoding", 252, 432, 59, 14)
Global $Input7 = GUICtrlCreateInput("", 12, 448, 206, 21)
Global $Button7 = GUICtrlCreateButton("...", 224, 448, 21, 21, 0)
GUICtrlSetOnEvent($Button7, "Button7Click")
Global $Label12 = GUICtrlCreateLabel("Font", 12, 432, 25, 17)
Global $Label18 = GUICtrlCreateLabel("Position (%)", 324, 432, 65, 14)
Global $Input8 = GUICtrlCreateInput("", 324, 448, 65, 21)
Global $Input9 = GUICtrlCreateInput("", 396, 448, 65, 21)
Global $Label19 = GUICtrlCreateLabel("Width (%)", 396, 432, 60, 14)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group6 = GUICtrlCreateGroup("Extra mencoder parameters", 84, 322, 177, 45, $BS_CENTER)
Global $Input10 = GUICtrlCreateInput("", 92, 338, 161, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group7 = GUICtrlCreateGroup("Resize method", 268, 50, 201, 69, $BS_CENTER)
Global $Radio1 = GUICtrlCreateRadio("Pan&Scan", 276, 66, 161, 17)
GUICtrlSetState($Radio1, $GUI_CHECKED)
Global $Radio2 = GUICtrlCreateRadio("Keep aspect", 276, 82, 161, 17)
Global $Radio3 = GUICtrlCreateRadio("Add borders", 276, 98, 169, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group11 = GUICtrlCreateGroup("Picture properties", 268, 122, 201, 173, $BS_CENTER)
Global $Slider4 = GUICtrlCreateSlider(276, 154, 154, 16, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider4, 100, 1)
GUICtrlSetData($Slider4, 10)
Global $Label2 = GUICtrlCreateLabel("Gamma", 276, 138, 46, 13)
Global $Label3 = GUICtrlCreateLabel("1", 436, 146, 25, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Label24 = GUICtrlCreateLabel("Contrast", 276, 202, 51, 13)
Global $Slider5 = GUICtrlCreateSlider(276, 218, 154, 16, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider5, 20, -20)
GUICtrlSetData($Slider5, 10)
Global $Label25 = GUICtrlCreateLabel("1", 436, 210, 25, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Label26 = GUICtrlCreateLabel("Brightness", 276, 170, 57, 13)
Global $Slider6 = GUICtrlCreateSlider(276, 186, 154, 16, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider6, 100, -10)
Global $Label27 = GUICtrlCreateLabel("0", 436, 178, 25, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Label28 = GUICtrlCreateLabel("Saturation", 276, 234, 58, 13)
Global $Slider7 = GUICtrlCreateSlider(276, 250, 154, 16, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider7, 30, 0)
GUICtrlSetData($Slider7, 10)
Global $Label29 = GUICtrlCreateLabel("1", 436, 242, 25, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Button13 = GUICtrlCreateButton("Default", 395, 272, 67, 17, 0)
GUICtrlSetOnEvent($Button13, "Button13Click")
Global $Checkbox5 = GUICtrlCreateCheckbox("Disable", 275, 271, 97, 17)
GUICtrlSetOnEvent($Checkbox5, "Checkbox5Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group12 = GUICtrlCreateGroup("Time interval", 4, 258, 257, 63, $BS_CENTER)
Global $Input12 = GUICtrlCreateInput("00", 12, 290, 33, 21)
GUICtrlSetState($Input12, $GUI_DISABLE)
Global $Input13 = GUICtrlCreateInput("00", 52, 290, 33, 21)
GUICtrlSetState($Input13, $GUI_DISABLE)
Global $Input14 = GUICtrlCreateInput("00", 92, 290, 33, 21)
GUICtrlSetState($Input14, $GUI_DISABLE)
Global $Input15 = GUICtrlCreateInput("00", 140, 290, 33, 21)
GUICtrlSetState($Input15, $GUI_DISABLE)
Global $Input16 = GUICtrlCreateInput("00", 180, 290, 33, 21)
GUICtrlSetState($Input16, $GUI_DISABLE)
Global $Input17 = GUICtrlCreateInput("00", 220, 290, 33, 21)
GUICtrlSetState($Input17, $GUI_DISABLE)
Global $Label30 = GUICtrlCreateLabel("-", 130, 293, 7, 17)
Global $Checkbox6 = GUICtrlCreateCheckbox("Use selected time interval", 12, 272, 241, 17)
GUICtrlSetOnEvent($Checkbox6, "Checkbox6Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group13 = GUICtrlCreateGroup("DVD", 4, 322, 73, 44, $BS_CENTER)
Global $Input19 = GUICtrlCreateInput("", 12, 338, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group15 = GUICtrlCreateGroup("Video filters", 268, 298, 201, 69)
Global $Checkbox7 = GUICtrlCreateCheckbox("Sharpen/Blur", 276, 314, 134, 15)
GUICtrlSetOnEvent($Checkbox7, "Checkbox7Click")
Global $Slider8 = GUICtrlCreateSlider(276, 330, 154, 16, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS), $WS_EX_STATICEDGE)
GUICtrlSetLimit($Slider8, 10, -10)
Global $Label31 = GUICtrlCreateLabel("0", 436, 323, 25, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
Global $Label32 = GUICtrlCreateLabel("Hint: -1..0 - sharpen, 0..1 - blur", 276, 348, 155, 14)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group16 = GUICtrlCreateGroup("MPlayer path", 4, 370, 225, 45)
Global $Input18 = GUICtrlCreateInput("mplayer", 12, 386, 209, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group17 = GUICtrlCreateGroup("MEncoder path", 236, 370, 233, 45)
Global $Input20 = GUICtrlCreateInput("mencoder", 244, 386, 215, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $TabSheet3 = GUICtrlCreateTabItem("Information")
Global $Label20 = GUICtrlCreateLabel($APPTITLE, 4, 50, 465, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont($Label20, 24, 800, 0, "MS Sans Serif")
Global $Label22 = GUICtrlCreateLabel($URL, 4, 269, 465, 28, $SS_CENTER)
GUICtrlSetFont($Label22, 14, 400, 4, "MS Sans Serif")
GUICtrlSetColor($Label22, 0x0000FF)
GUICtrlSetOnEvent($Label22, "Label22Click")
GUICtrlSetCursor($Label22, 0)
Global $Edit2 = GUICtrlCreateEdit("", 4, 297, 465, 181, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))
GUICtrlSetData($Edit2, StringFormat($APPTITLE & " uses mplayer and mencoder - http://www.mplayerhq.hu/\r\nAlso, the DejaVu Sans font - http://sourceforge.net/projects/dejavu\r\n\r\n" & $APPTITLE & " е is written in AutoIt - \r\nhttp://www.autoitscript.com/\r\nThe viDrop.au3 file is the source code.\r\nThe AForm1.kxf file is the Koda Form Designer GUI definition for the script. \r\n" & $APPTITLE & " is distributed under the terms of GPL3 license. \r\nSee gpl-3.0.txt file in the " & $APPTITLE & " installation directory for details.\r\n"))
Global $Label1 = GUICtrlCreateLabel($CREDIT, 4, 252, 465, 17, $SS_CENTER)
Global $Group14 = GUICtrlCreateGroup("Version", 168, 104, 137, 65, $BS_CENTER)
Global $Button14 = GUICtrlCreateButton("Check for update", 184, 136, 107, 25, 0)
GUICtrlSetOnEvent($Button14, "CheckForUpdate")
Global $Label21 = GUICtrlCreateLabel($APPVERSION, 170, 119, 133, 17, $SS_CENTER)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
Global $Combo4 = GUICtrlCreateCombo("", 70, 0, 224, 25)
GUICtrlSetOnEvent($Combo4, "Combo4Change")
Global $Label23 = GUICtrlCreateLabel("Preset:", 3, 3, 37, 17)
Global $Button11 = GUICtrlCreateButton("Delete", 390, 0, 83, 21, 0)
GUICtrlSetOnEvent($Button11, "Button11Click")
Global $Button12 = GUICtrlCreateButton("Save", 300, 0, 83, 21, 0)
GUICtrlSetOnEvent($Button12, "Button12Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $WM_DROPFILES = 0x233

Global Const $TBM_SETTIPSIDE = $WM_USER + 31
Global Const $WM_HSCROLL = 0x0114
Global $gaDropFiles[1], $str = ""
Global $vidinfo[11]
Global $update_size

GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")
GUISetOnEvent($GUI_EVENT_DROPPED, "SpecialEvents")
GUICtrlSetState($Input1, $GUI_DROPACCEPTED)

GUIRegisterMsg($WM_HSCROLL, "trackbar_change")


_SendMessage(GUICtrlGetHandle($Slider1), $TBM_SETTICFREQ, 128, 0)
_SendMessage(GUICtrlGetHandle($Slider2), $TBM_SETTICFREQ, 1, 0)
_SendMessage(GUICtrlGetHandle($Slider3), $TBM_SETTICFREQ, 1, 0)

GUISetState(@SW_SHOW)
LoadSettings(@ScriptDir & '\' & $APPTITLE & '.ini')
ListPresets()
If UBound($CmdLine) > 1 Then
    If UBound($CmdLine) > 2 Then
        For $i = 0 To UBound($CmdLine) - 1
            OpenFile($CmdLine[$i])
        Next
    Else
        OpenFile($CmdLine[1])
    EndIf
EndIf

While 1
    Sleep(100)
WEnd

Func ListPresets()
    GUICtrlSetData($Combo4, "||")
    Local $search = FileFindFirstFile(@ScriptDir & "\presets\*.ini")
    If $search = -1 Then Return
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        GUICtrlSetData($Combo4, $file & "|")
    WEnd
    FileClose($search)
EndFunc   ;==>ListPresets

Func Combo4Change()
    If FileExists(@ScriptDir & "\presets\" & GUICtrlRead($Combo4)) Then
        LoadSettings(@ScriptDir & "\presets\" & GUICtrlRead($Combo4))
    EndIf
EndFunc   ;==>Combo4Change

Func SaveSettings($file)
    Local $data
    $data &= 'RebuildIndex=' & Number(GUICtrlRead($Checkbox1) == $GUI_CHECKED) & @LF
    $data &= 'AutoAddOnOpen=' & Number(GUICtrlRead($Checkbox2) == $GUI_CHECKED) & @LF
    $data &= 'Normalize=' & Number(GUICtrlRead($Checkbox3) == $GUI_CHECKED) & @LF
    $data &= 'NormalizeAmount=' & GUICtrlRead($Slider9) / 100 & @LF
    $data &= 'ExtraStereo=' & Number(GUICtrlRead($Checkbox4) == $GUI_CHECKED) & @LF
    $data &= 'SRate=' & GUICtrlRead($Combo1) & @LF
    $data &= 'VideoCodec=' & GUICtrlRead($Combo2) & @LF
    $data &= 'AudioCodec=' & GUICtrlRead($Combo3) & @LF
    $data &= 'VideoBitrate=' & GUICtrlRead($Slider1) & @LF
    $data &= 'AudioBitrate=' & GUICtrlRead($Slider2) & @LF
    $data &= 'MotionEst=' & GUICtrlRead($Slider3) & @LF
    $data &= 'Width=' & GUICtrlRead($Input4) & @LF
    $data &= 'Height=' & GUICtrlRead($Input5) & @LF
    $data &= 'SubFont=' & GUICtrlRead($Input7) & @LF
    $data &= 'SubCP=' & GUICtrlRead($Input6) & @LF
    $data &= 'SupPos=' & GUICtrlRead($Input8) & @LF
    $data &= 'SubWidth=' & GUICtrlRead($Input9) & @LF
    $data &= 'CmdLine=' & GUICtrlRead($Input10) & @LF
    $data &= 'FPS=' & GUICtrlRead($Input11) & @LF

    $data &= 'pp=' & GUICtrlRead($Checkbox5) & @LF
    
    If GUICtrlRead($Checkbox5) == $GUI_CHECKED Then
        $data &= 'pp=0' & @LF
    Else
        $data &= 'pp=1' & @LF
    EndIf
    
    If GUICtrlRead($Checkbox7) == $GUI_CHECKED Then
        $data &= 'smartblur=1' & @LF
    Else
        $data &= 'smartblur=0' & @LF
    EndIf
    $data &= 'smartblur-amount=' & GUICtrlRead($Slider8) / 10 & @LF
    
    $data &= 'gamma=' & GUICtrlRead($Slider4) / 10 & @LF
    $data &= 'contrast=' & GUICtrlRead($Slider5) / 10 & @LF
    $data &= 'brightness=' & GUICtrlRead($Slider6) / 10 & @LF
    $data &= 'saturation=' & GUICtrlRead($Slider7) / 10 & @LF
    
    $data &= 'dvd-device=' & GUICtrlRead($Input19) & @LF
    
    $data &= 'mplayer-path=' & GUICtrlRead($Input18) & @LF
    $data &= 'mencoder-path=' & GUICtrlRead($Input20) & @LF
    
    
    If GUICtrlRead($Radio1) == $GUI_CHECKED Then
        $data &= 'ResizeMethod=1' & @LF
    ElseIf GUICtrlRead($Radio2) == $GUI_CHECKED Then
        $data &= 'ResizeMethod=2' & @LF
    ElseIf GUICtrlRead($Radio3) == $GUI_CHECKED Then
        $data &= 'ResizeMethod=3' & @LF
    EndIf
    
    IniWriteSection($file, 'settings', $data)
EndFunc   ;==>SaveSettings

Func LoadSettings($file = "")
    If IniRead($file, 'settings', 'RebuildIndex', 1) == 1 Then
        GUICtrlSetState($Checkbox1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    EndIf
    
    If IniRead($file, 'settings', 'AutoAddOnOpen', 0) == 1 Then
        GUICtrlSetState($Checkbox2, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    EndIf
    
    If IniRead($file, 'settings', 'Normalize', 1) == 1 Then
        GUICtrlSetState($Checkbox3, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
    EndIf
    GUICtrlSetData($Slider9, IniRead($file, 'settings', 'NormalizeAmount', 0.25) * 100)
    GUICtrlSetData($Label33, IniRead($file, 'settings', 'NormalizeAmount', 0.25))
    
    Checkbox3Click()
    
    
    If IniRead($file, 'settings', 'ExtraStereo', 0) == 1 Then
        GUICtrlSetState($Checkbox4, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
    EndIf

    If IniRead($file, 'settings', 'pp', 1) == 1 Then
        GUICtrlSetState($Checkbox5, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
    EndIf
    Checkbox5Click()
    
    If IniRead($file, 'settings', 'smartblur', 0) == 1 Then
        GUICtrlSetState($Checkbox7, $GUI_CHECKED)
    Else
        GUICtrlSetState($Checkbox7, $GUI_UNCHECKED)
    EndIf
    Checkbox7Click()
    _GUICtrlComboSelectString($Combo1, -1, IniRead($file, 'settings', 'SRate', 44100))
    _GUICtrlComboSelectString($Combo2, -1, IniRead($file, 'settings', 'VideoCodec', 'xvid'))
    _GUICtrlComboSelectString($Combo3, -1, IniRead($file, 'settings', 'AudioCodec', 'mp2'))
    
    GUICtrlSetData($Slider1, IniRead($file, 'settings', 'VideoBitrate', 300))
    GUICtrlSetData($Slider2, IniRead($file, 'settings', 'AudioBitrate', 7))
    GUICtrlSetData($Slider3, IniRead($file, 'settings', 'MotionEst', 4))
    
    GUICtrlSetData($Input4, IniRead($file, 'settings', 'Width', 320))
    GUICtrlSetData($Input5, IniRead($file, 'settings', 'Height', 240))
    GUICtrlSetData($Input6, IniRead($file, 'settings', 'SubCP', 'cp1251'))
    GUICtrlSetData($Input7, IniRead($file, 'settings', 'SubFont', '.\mplayer\subfont.ttf'))
    GUICtrlSetData($Input8, IniRead($file, 'settings', 'SupPos', 100))
    GUICtrlSetData($Input9, IniRead($file, 'settings', 'SubWidth', 100))
    GUICtrlSetData($Input10, IniRead($file, 'settings', 'CmdLine', ''))
    GUICtrlSetData($Input11, IniRead($file, 'settings', 'FPS', '22'))
    
    GUICtrlSetData($Input18, IniRead($file, 'settings', 'mplayer-path', 'mplayer'))
    GUICtrlSetData($Input20, IniRead($file, 'settings', 'mencoder-path', 'mencoder'))
    
    GUICtrlSetData($Slider4, IniRead($file, 'settings', 'gamma', 1) * 10)
    GUICtrlSetData($Slider5, IniRead($file, 'settings', 'contrast', 1) * 10)
    GUICtrlSetData($Slider6, IniRead($file, 'settings', 'brightness', 0) * 10)
    GUICtrlSetData($Slider7, IniRead($file, 'settings', 'saturation', 1) * 10)
    
    GUICtrlSetData($Slider8, IniRead($file, 'settings', 'smartblur-amount', 0) * 10)
    GUICtrlSetData($Input19, IniRead($file, 'settings', 'dvd-device', ''))
    
    GUICtrlSetData($Label5, GUICtrlRead($Slider1))
    GUICtrlSetData($Label7, GUICtrlRead($Slider2) * 16)
    GUICtrlSetData($Label11, GUICtrlRead($Slider3))
    
    GUICtrlSetData($Label3, GUICtrlRead($Slider4) / 10)
    GUICtrlSetData($Label25, GUICtrlRead($Slider5) / 10)
    GUICtrlSetData($Label27, GUICtrlRead($Slider6) / 10)
    GUICtrlSetData($Label29, GUICtrlRead($Slider7) / 10)
    
    Switch IniRead($file, 'settings', 'ResizeMethod', '1')
        Case 1
            GUICtrlSetState($Radio1, $GUI_CHECKED)
        Case 2
            GUICtrlSetState($Radio2, $GUI_CHECKED)
        Case 3
            GUICtrlSetState($Radio3, $GUI_CHECKED)
    EndSwitch
    Combo2Change()
    Combo3Change()
    CalcOutputSize()
EndFunc   ;==>LoadSettings

Func CalcOutputSize()
    WinSetTitle($AForm1, "", $APPTITLE & ' (Output size: ~' & Round($vidinfo[10] * (GUICtrlRead($Slider1) + GUICtrlRead($Slider2) * 16) / 8 / 1024, 2) & ' MB)')
EndFunc   ;==>CalcOutputSize

Func trackbar_change($hWnd, $Msg, $wParam, $lParam)
    Switch $lParam
        Case GUICtrlGetHandle($Slider1)
            GUICtrlSetData($Label5, GUICtrlRead($Slider1))
            CalcOutputSize()
        Case GUICtrlGetHandle($Slider2)
            GUICtrlSetData($Label7, GUICtrlRead($Slider2) * 16)
            CalcOutputSize()
        Case GUICtrlGetHandle($Slider3)
            GUICtrlSetData($Label11, GUICtrlRead($Slider3))
            
            
        Case GUICtrlGetHandle($Slider4)
            GUICtrlSetData($Label3, GUICtrlRead($Slider4) / 10)
        Case GUICtrlGetHandle($Slider5)
            GUICtrlSetData($Label25, GUICtrlRead($Slider5) / 10)
        Case GUICtrlGetHandle($Slider6)
            GUICtrlSetData($Label27, GUICtrlRead($Slider6) / 10)
        Case GUICtrlGetHandle($Slider7)
            GUICtrlSetData($Label29, GUICtrlRead($Slider7) / 10)
            
        Case GUICtrlGetHandle($Slider8)
            GUICtrlSetData($Label31, GUICtrlRead($Slider8) / 10)
            
        Case GUICtrlGetHandle($Slider9)
            GUICtrlSetData($Label33, GUICtrlRead($Slider9) / 100)
    EndSwitch
EndFunc   ;==>trackbar_change

Func getVidInfo($file)
    Global $vidinfo[11]
    If GUICtrlRead($Input19) <> '' Then
        $cmd = GUICtrlRead($Input18) & ' -slave -identify -quiet -frames 0 -vo null -ao null -dvd-device ' & GUICtrlRead($Input19) & ' "' & $file & '"'
        
    Else
        $cmd = GUICtrlRead($Input18) & ' -slave -identify -quiet -frames 0 -vo null -ao null "' & $file & '"'
    EndIf
    SplashTextOn("", "Зареждане. Моля изчакайте...", 320, 32, -1, -1, 1 + 32, "", 16, 1000)

    FileChangeDir(@ScriptDir)
    $pid = Run($cmd, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
    $text = ""
    While ProcessExists($pid)
        $text &= StdoutRead($pid)
    WEnd
    SplashOff()
    $out = StringSplit($text, @CRLF, 1)
    $count = $out[0]
    For $i = 1 To $count
        $line = $out[$i]
        $str = StringRegExp($line, '^([a-zA-Z_].*)=(.*?)$', 1)
        If @error = 0 Then
            Switch $str[0]
                Case 'ID_DEMUXER'
                    $vidinfo[0] = $str[1]
                Case 'ID_VIDEO_FORMAT'
                    $vidinfo[1] = $str[1]
                Case 'ID_VIDEO_BITRATE'
                    $vidinfo[2] = $str[1]
                Case 'ID_VIDEO_WIDTH'
                    $vidinfo[3] = $str[1]
                Case 'ID_VIDEO_HEIGHT'
                    $vidinfo[4] = $str[1]
                Case 'ID_VIDEO_FPS'
                    $vidinfo[5] = $str[1]
                Case 'ID_AUDIO_CODEC'
                    $vidinfo[6] = $str[1]
                Case 'ID_AUDIO_BITRATE'
                    $vidinfo[7] = $str[1]
                Case 'ID_AUDIO_RATE'
                    $vidinfo[8] = $str[1]
                Case 'ID_AUDIO_NCH'
                    $vidinfo[9] = $str[1]
                Case 'ID_LENGTH'
                    $vidinfo[10] = $str[1]
            EndSwitch
        EndIf
    Next
    
    $seconds = Round(Mod($vidinfo[10], 60), 2)
    $minutes = Int($vidinfo[10] - $seconds) / 60
    $hours = Int($minutes - Mod($minutes, 3600))
    
    GUICtrlSetData($Input15, $hours)
    GUICtrlSetData($Input16, $minutes)
    GUICtrlSetData($Input17, $seconds)
EndFunc   ;==>getVidInfo

Func Input1Change()
    OpenFile(GUICtrlRead($Input1))
EndFunc   ;==>Input1Change

Func Button1Click()
    $movie = FileOpenDialog("Select input A/V File", "", "Multimedia files (*.avi;*.mpg;*.mpeg;*.3gp;*.qt;*.mp1;*.mp2;*.wmv;*.asf;*.asf;*.swf;*.flv;*.rm;*.mov;*.mp4;*.dv)", 1)
    If $movie <> '' Then
        OpenFile($movie)
    EndIf
EndFunc   ;==>Button1Click

Func Button2Click()
    $isub = FileOpenDialog("Select input subtitle", "", "Subtitles (*.sub;*.txt;*.srt)", 1, GUICtrlRead($Input2))
    If $isub <> '' Then
        GUICtrlSetData($Input2, $isub)
    EndIf
EndFunc   ;==>Button2Click

Func Button3Click()
    $outf = FileSaveDialog("Select output file", "", "Avi files (*.avi;)", 0, GUICtrlRead($Input3))
    If $outf <> '' Then
        GUICtrlSetData($Input3, $outf)
    EndIf
EndFunc   ;==>Button3Click

Func Button4Click()
    Local $cmd = GenerateCommandLine()
    GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & $cmd & @CRLF)
EndFunc   ;==>Button4Click

Func GenerateCommandLine($preview = False, $twopass = False)
    Local $sInputVideo = GUICtrlRead($Input1)
    Local $sInputSubtitle = GUICtrlRead($Input2)
    Local $sOutputVideo = GUICtrlRead($Input3)
    Local $iVideoMotionEstimation = GUICtrlRead($Slider3)
    Local $iVideoBitrate = GUICtrlRead($Slider1)
    Local $iAudioBitrate = GUICtrlRead($Slider2) * 16
    Local $iWidth = GUICtrlRead($Input4)
    Local $iHeight = GUICtrlRead($Input5)
    Local $fZoom = 1
    Local $iSRate = GUICtrlRead($Combo1)
    Local $sVideoCodec = GUICtrlRead($Combo2)
    Local $sAudioCodec = GUICtrlRead($Combo3)

    ;for WINE compatibility
    Local $cmd = GUICtrlRead($Input20) & ' "' & $sInputVideo & '" -cache 16384 -idx -noodml -of avi'

    If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then ;force rebuild index
        $cmd &= ' -forceidx'
    EndIf
    
    Switch $sVideoCodec
        Case 'copy'
            $cmd &= ' -ovc copy'
        Case 'xvid'
            $cmd &= ' -ovc xvid -xvidencopts bitrate=' & $iVideoBitrate & ':max_bframes=0:quant_type=h263:me_quality=' & $iVideoMotionEstimation
            $cmd &= ':turbo:nochroma_me:notrellis:vhq=0'
            
            If GUICtrlRead($Radio1) == $GUI_CHECKED Then
                $cmd &= ' -vf-add scale=-2:' & $iHeight & ',crop=' & $iWidth & ':' & $iHeight
            ElseIf GUICtrlRead($Radio2) == $GUI_CHECKED Then
                $cmd &= ' -vf-add scale=' & $iWidth & ':-2'
            ElseIf GUICtrlRead($Radio3) == $GUI_CHECKED Then
                $cmd &= ' -vf-add scale=' & $iWidth & ':-2,expand=:::::' & $iWidth & '/' & $iHeight
            EndIf
            
            If FileExists($sInputSubtitle) Then
                $cmd &= ' -sub "' & $sInputSubtitle & '" -subcp ' & GUICtrlRead($Input6) & ' -font "' & GUICtrlRead($Input7) & '" -subpos ' & GUICtrlRead($Input8) & ' -subwidth ' & GUICtrlRead($Input9) & ' -subfont-text-scale 5'
            Else
                $cmd &= ''
            EndIf
    EndSwitch
    
    If GUICtrlRead($Input11) > 0 Then
        $cmd &= ' -ofps ' & GUICtrlRead($Input11)
    EndIf
    
    Switch $sAudioCodec
        Case 'copy'
            $cmd &= ' -oac copy'
        Case 'mp2'
            $cmd &= ' -oac lavc -lavcopts acodec=mp2:abitrate=' & $iAudioBitrate & ' -srate ' & $iSRate
            If GUICtrlRead($Checkbox3) == $GUI_CHECKED Then
                $cmd &= ' -af volnorm=2:' & GUICtrlRead($Slider9) / 100
            EndIf
            If GUICtrlRead($Checkbox4) == $GUI_CHECKED Then
                $cmd &= ' -af extrastereo=2.5'
            EndIf
        Case 'mp3'
            $cmd &= ' -oac mp3lame -lameopts mode=1:cbr:br=' & $iAudioBitrate & ' -srate ' & $iSRate
            If GUICtrlRead($Checkbox3) == $GUI_CHECKED Then
                $cmd &= ' -af volnorm=2:' & GUICtrlRead($Slider9) / 100
            EndIf
            If GUICtrlRead($Checkbox4) == $GUI_CHECKED Then
                $cmd &= ' -af extrastereo=2.5'
            EndIf
        Case 'nosound'
            $cmd &= ' -nosound'
    EndSwitch
    
    If $preview Then
        $cmd &= ' -ss ' & Round(Random(0, $vidinfo[10])) & ' -endpos 15'
        $cmd &= ' -o "' & @TempDir & '\preview.avi" '
    Else
        If GUICtrlRead($Checkbox6) == $GUI_CHECKED Then
            Local $ss = 60 * 60 * GUICtrlRead($Input12) + 60 * GUICtrlRead($Input13) + GUICtrlRead($Input14)
            Local $endpos = 60 * 60 * GUICtrlRead($Input15) + 60 * GUICtrlRead($Input16) + GUICtrlRead($Input17)
            $cmd &= ' -ss ' & $ss
            $cmd &= ' -endpos ' & $endpos - $ss
            
        EndIf
        $cmd &= ' -o "' & $sOutputVideo & '" '
    EndIf
    
    If GUICtrlRead($Checkbox5) == $GUI_UNCHECKED Then
        $cmd &= ' -vf-add eq2=' & _
                GUICtrlRead($Slider4) / 10 & ':' & _
                GUICtrlRead($Slider5) / 10 & ':' & _
                GUICtrlRead($Slider6) / 10 & ':' & _
                GUICtrlRead($Slider7) / 10 & ':::: '
    EndIf
    
    If GUICtrlRead($Checkbox7) == $GUI_CHECKED Then
        $cmd &= ' -vf-add smartblur=5:' & GUICtrlRead($Slider8) / 10 & ':0'
    EndIf
    
    If GUICtrlRead($Input19) <> '' Then
        $cmd &= ' -dvd-device ' & GUICtrlRead($Input19)
    EndIf
    
    $cmd &= GUICtrlRead($Input10)
    $cmd &= ' -vf-add harddup '
    
    Return $cmd
EndFunc   ;==>GenerateCommandLine

Func Checkbox3Click()
    If GUICtrlRead($Checkbox3) == $GUI_CHECKED Then
        GUICtrlSetState($Slider9, $GUI_ENABLE)
        GUICtrlSetState($Label33, $GUI_ENABLE)
    ElseIf GUICtrlRead($Checkbox3) == $GUI_UNCHECKED Then
        GUICtrlSetState($Slider9, $GUI_DISABLE)
        GUICtrlSetState($Label33, $GUI_DISABLE)
    EndIf
EndFunc   ;==>Checkbox3Click

Func Checkbox7Click()
    If GUICtrlRead($Checkbox7) == $GUI_CHECKED Then
        GUICtrlSetState($Slider8, $GUI_ENABLE)
        GUICtrlSetState($Label31, $GUI_ENABLE)
    ElseIf GUICtrlRead($Checkbox7) == $GUI_UNCHECKED Then
        GUICtrlSetState($Slider8, $GUI_DISABLE)
        GUICtrlSetState($Label31, $GUI_DISABLE)
    EndIf
EndFunc   ;==>Checkbox7Click

Func Button7Click()
    $subfont = FileSaveDialog("Select subtitle font", "", "Fonts (*.ttf;)", 0, GUICtrlRead($Input7))
    If $subfont <> '' Then
        GUICtrlSetData($Input7, $subfont)
    EndIf
EndFunc   ;==>Button7Click

Func Button5Click()
    $batch = GUICtrlRead($Edit1)
    $batch = StringStripCR($batch)
    $batch = StringSplit($batch, @LF)

    GUISetState(@SW_HIDE)
    Opt("TrayIconHide", 0)
    Opt("TrayAutoPause", 0)

    For $i = 1 To UBound($batch) - 1
        If $batch[$i] <> "" Then
            $text = "Converting file " & $i & " от " & UBound($batch) - 2
            $text &= @CRLF & $batch[$i]
            TraySetToolTip($text)
            TrayTip("Running batch", $text, 10, 1 + 16)
            FileChangeDir(@ScriptDir)
            RunWait($batch[$i], @ScriptDir, @SW_MINIMIZE)
        EndIf
    Next
    TraySetToolTip()
    Opt("TrayIconHide", 1)
    GUISetState(@SW_SHOW)
EndFunc   ;==>Button5Click

Func Button6Click()
    If MsgBox(32 + 4, "Confirm", "Clear all batch jobs?") == 6 Then
        GUICtrlSetData($Edit1, "")
    EndIf
EndFunc   ;==>Button6Click

Func Button8Click()
    $tip = "------------------------------------------------" & @CRLF
    $tip &= "Length:    " & $vidinfo[10] & " sec" & @CRLF
    $tip &= "FPS:   " & $vidinfo[5] & @CRLF
    $tip &= "Width:     " & $vidinfo[3] & @CRLF
    $tip &= "Height:    " & $vidinfo[4] & @CRLF
    $tip &= "Video bitrate: " & $vidinfo[2] / 1000 & " kbit/s" & @CRLF
    $tip &= "Audio bitrate: " & $vidinfo[7] / 1000 & " kbit/s" & @CRLF
    $tip &= "Video codec:   " & $vidinfo[1] & @CRLF
    $tip &= "Audio codec:   " & $vidinfo[6] & @CRLF
    $tip &= "Audio nCh.:    " & $vidinfo[9]
    $tip &= @CRLF & "------------------------------------------------"
    MsgBox(0, "Information:", $tip)
EndFunc   ;==>Button8Click

Func Button9Click()
    Local $cmd = GenerateCommandLine()
    GUISetState(@SW_HIDE)
    FileChangeDir(@ScriptDir)
    RunWait($cmd, @ScriptDir, @SW_SHOW)
    GUISetState(@SW_SHOW)
EndFunc   ;==>Button9Click

Func Button10Click()
    Local $cmd = GenerateCommandLine(True)
    GUISetState(@SW_HIDE)
    FileChangeDir(@ScriptDir)
    RunWait($cmd, @ScriptDir, @SW_SHOW)
    FileChangeDir(@ScriptDir)
    RunWait(GUICtrlRead($Input18) & ' "' & @TempDir & '/preview.avi' & '"', @ScriptDir)
    GUISetState(@SW_SHOW)
EndFunc   ;==>Button10Click

Func Button11Click()
    If (GUICtrlRead($Combo4) == '') Then
        MsgBox(48, "Error", "No profile chosen.")
    Else
        If MsgBox(4 + 32, "Confirm", "Delete this profile?") == 6 Then
            FileDelete(@ScriptDir & "\presets\" & GUICtrlRead($Combo4))
            ListPresets()
            LoadSettings()
        EndIf
    EndIf

EndFunc   ;==>Button11Click

Func Button12Click()
    Local $target = GUICtrlRead($Combo4)
    If $target == '' Then
        MsgBox(48, "Error", "No name gven!")
    Else
        Local $file = @ScriptDir & "\presets\" & $target
        If $target <> '' Then
            If StringInStr($file, '.ini') = 0 Then
                $file &= '.ini'
            EndIf
            SaveSettings($file)
            ListPresets()
            _GUICtrlComboSelectString($Combo4, -1, $target)
        EndIf
    EndIf
EndFunc   ;==>Button12Click

Func Button13Click()
    GUICtrlSetData($Slider4, 10)
    GUICtrlSetData($Slider5, 10)
    GUICtrlSetData($Slider6, 0)
    GUICtrlSetData($Slider7, 10)
    
    GUICtrlSetData($Label3, GUICtrlRead($Slider4) / 10)
    GUICtrlSetData($Label25, GUICtrlRead($Slider5) / 10)
    GUICtrlSetData($Label27, GUICtrlRead($Slider6) / 10)
    GUICtrlSetData($Label29, GUICtrlRead($Slider7) / 10)
EndFunc   ;==>Button13Click

Func Button15Click()
    GUICtrlSetData($Slider9, 25)
    GUICtrlSetData($Label33, 0.25)
EndFunc   ;==>Button15Click

Func Checkbox5Click()
    ;MsgBox(0,$GUI_CHECKED,GUICtrlRead($Checkbox5))
    If GUICtrlRead($Checkbox5) == $GUI_CHECKED Then
        GUICtrlSetState($Slider4, $GUI_DISABLE)
        GUICtrlSetState($Slider5, $GUI_DISABLE)
        GUICtrlSetState($Slider6, $GUI_DISABLE)
        GUICtrlSetState($Slider7, $GUI_DISABLE)
        GUICtrlSetState($Label2, $GUI_DISABLE)
        GUICtrlSetState($Label3, $GUI_DISABLE)
        GUICtrlSetState($Label24, $GUI_DISABLE)
        GUICtrlSetState($Label25, $GUI_DISABLE)
        GUICtrlSetState($Label26, $GUI_DISABLE)
        GUICtrlSetState($Label27, $GUI_DISABLE)
        GUICtrlSetState($Label28, $GUI_DISABLE)
        GUICtrlSetState($Label29, $GUI_DISABLE)
        
    ElseIf GUICtrlRead($Checkbox5) == $GUI_UNCHECKED Then
        GUICtrlSetState($Slider4, $GUI_ENABLE)
        GUICtrlSetState($Slider5, $GUI_ENABLE)
        GUICtrlSetState($Slider6, $GUI_ENABLE)
        GUICtrlSetState($Slider7, $GUI_ENABLE)
        GUICtrlSetState($Label2, $GUI_ENABLE)
        GUICtrlSetState($Label3, $GUI_ENABLE)
        GUICtrlSetState($Label24, $GUI_ENABLE)
        GUICtrlSetState($Label25, $GUI_ENABLE)
        GUICtrlSetState($Label26, $GUI_ENABLE)
        GUICtrlSetState($Label27, $GUI_ENABLE)
        GUICtrlSetState($Label28, $GUI_ENABLE)
        GUICtrlSetState($Label29, $GUI_ENABLE)
    EndIf
EndFunc   ;==>Checkbox5Click

Func Checkbox6Click()
    If GUICtrlRead($Checkbox6) == $GUI_UNCHECKED Then
        GUICtrlSetState($Input12, $GUI_DISABLE)
        GUICtrlSetState($Input13, $GUI_DISABLE)
        GUICtrlSetState($Input14, $GUI_DISABLE)
        GUICtrlSetState($Input15, $GUI_DISABLE)
        GUICtrlSetState($Input16, $GUI_DISABLE)
        GUICtrlSetState($Input17, $GUI_DISABLE)
    Else
        GUICtrlSetState($Input12, $GUI_ENABLE)
        GUICtrlSetState($Input13, $GUI_ENABLE)
        GUICtrlSetState($Input14, $GUI_ENABLE)
        GUICtrlSetState($Input15, $GUI_ENABLE)
        GUICtrlSetState($Input16, $GUI_ENABLE)
        GUICtrlSetState($Input17, $GUI_ENABLE)
    EndIf
EndFunc   ;==>Checkbox6Click

Func Combo2Change()
    Switch GUICtrlRead($Combo2)
        Case 'copy'
            GUICtrlSetState($Label4, $GUI_DISABLE)
            GUICtrlSetState($Label5, $GUI_DISABLE)
            GUICtrlSetState($Label8, $GUI_DISABLE)
            GUICtrlSetState($Label9, $GUI_DISABLE)
            GUICtrlSetState($Label10, $GUI_DISABLE)
            GUICtrlSetState($Label11, $GUI_DISABLE)
            GUICtrlSetState($Label13, $GUI_DISABLE)
            GUICtrlSetState($Input4, $GUI_DISABLE)
            GUICtrlSetState($Input5, $GUI_DISABLE)
            GUICtrlSetState($Input11, $GUI_DISABLE)
            GUICtrlSetState($Slider1, $GUI_DISABLE)
            GUICtrlSetState($Slider3, $GUI_DISABLE)
            GUICtrlSetState($Radio1, $GUI_DISABLE)
            GUICtrlSetState($Radio2, $GUI_DISABLE)
            GUICtrlSetState($Radio3, $GUI_DISABLE)
        Case 'xvid'
            GUICtrlSetState($Label4, $GUI_ENABLE)
            GUICtrlSetState($Label5, $GUI_ENABLE)
            GUICtrlSetState($Label8, $GUI_ENABLE)
            GUICtrlSetState($Label9, $GUI_ENABLE)
            GUICtrlSetState($Label10, $GUI_ENABLE)
            GUICtrlSetState($Label11, $GUI_ENABLE)
            GUICtrlSetState($Label13, $GUI_ENABLE)
            GUICtrlSetState($Input4, $GUI_ENABLE)
            GUICtrlSetState($Input5, $GUI_ENABLE)
            GUICtrlSetState($Input11, $GUI_ENABLE)
            GUICtrlSetState($Slider1, $GUI_ENABLE)
            GUICtrlSetState($Slider3, $GUI_ENABLE)
            GUICtrlSetState($Radio1, $GUI_ENABLE)
            GUICtrlSetState($Radio2, $GUI_ENABLE)
            GUICtrlSetState($Radio3, $GUI_ENABLE)
    EndSwitch
EndFunc   ;==>Combo2Change

Func Combo3Change()
    Switch GUICtrlRead($Combo3)
        Case 'copy', 'nosound'
            GUICtrlSetState($Label6, $GUI_DISABLE)
            GUICtrlSetState($Label7, $GUI_DISABLE)
            GUICtrlSetState($Label14, $GUI_DISABLE)
            GUICtrlSetState($Combo1, $GUI_DISABLE)
            GUICtrlSetState($Slider2, $GUI_DISABLE)
            GUICtrlSetState($Checkbox3, $GUI_DISABLE)
            GUICtrlSetState($Checkbox4, $GUI_DISABLE)
        Case 'mp2'
            GUICtrlSetState($Label6, $GUI_ENABLE)
            GUICtrlSetState($Label7, $GUI_ENABLE)
            GUICtrlSetState($Label14, $GUI_ENABLE)
            GUICtrlSetState($Combo1, $GUI_ENABLE)
            GUICtrlSetState($Slider2, $GUI_ENABLE)
            GUICtrlSetState($Checkbox3, $GUI_ENABLE)
            GUICtrlSetState($Checkbox4, $GUI_ENABLE)
    EndSwitch
EndFunc   ;==>Combo3Change

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            SaveSettings(@ScriptDir & '\' & $APPTITLE & '.ini')
            Exit
        Case @GUI_CtrlId = $GUI_EVENT_DROPPED
            If UBound($gaDropFiles) > 1 And GUICtrlRead($Checkbox2) == $GUI_CHECKED Then
                For $i = 0 To UBound($gaDropFiles) - 1
                    OpenFile($gaDropFiles[$i])
                Next
            Else
                OpenFile($gaDropFiles[0])
            EndIf
            
    EndSelect
EndFunc   ;==>SpecialEvents

Func OpenFile($movie)
    GUICtrlSetData($Input1, $movie)
    Local $szDrive, $szDir, $szFName, $szExt
    $path = _PathSplit($movie, $szDrive, $szDir, $szFName, $szExt)
    If FileExists($path[1] & $path[2] & $path[3] & '.txt') Then
        $isub = $path[1] & $path[2] & $path[3] & '.txt'
    ElseIf FileExists($path[1] & $path[2] & $path[3] & '.sub') Then
        $isub = $path[1] & $path[2] & $path[3] & '.sub'
    ElseIf FileExists($path[1] & $path[2] & $path[3] & '.srt') Then
        $isub = $path[1] & $path[2] & $path[3] & '.srt'
    Else
        $isub = ''
    EndIf
    $outf = $path[1] & $path[2] & $path[3] & '_converted' & '.avi'
    GUICtrlSetData($Input2, $isub)
    GUICtrlSetData($Input3, $outf)
    getVidInfo($movie)
    CalcOutputSize()
    If GUICtrlRead($Checkbox2) == $GUI_CHECKED Then
        Button4Click()
    EndIf
EndFunc   ;==>OpenFile

Func WM_DROPFILES($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc   ;==>WM_DROPFILES

Func OnAutoItExit()
    FileDelete(@TempDir & '\preview.avi')
EndFunc   ;==>OnAutoItExit

Func Label22Click()
    Run(@ComSpec & " /c start " & $URL, "", @SW_HIDE)
EndFunc   ;==>Label22Click

Func CheckForUpdate()
    $ver = _INetGetSource('http://users2.titanichost.com/lokster/en/vidrop-version.txt')
    If @error Then
        MsgBox(16, 'Error', 'Error checking for update! Maybe your internet connection is not active?')
    Else
        $ver = StringSplit($ver, " ")
        
        If ($ver[1] > $APPVERSION) Then
            Local $ans = MsgBox(4 + 32, 'Question', 'There is update available - ' & $ver[1] & ' (' & $ver[2] & '). Do you want to download it?')
            If $ans == 6 Then
                DownloadUpdate($ver[1])
            EndIf
        Else
            MsgBox(64, 'Information', 'You already have the latest version - ' & $APPVERSION & ' (' & $APPVERSION_MINOR & '). No update is needed.')
        EndIf
    EndIf
EndFunc   ;==>CheckForUpdate

Func DownloadUpdate($version)
    GUICtrlSetState($Button14, $GUI_DISABLE)
    AdlibEnable('CheckBytesDownloaded', 500)
    DirCreate(@ScriptDir & '\update')
    Global $update_size = InetGetSize('http://users2.titanichost.com/lokster/en/vidrop-' & $version & '-install.exe')
    InetGet('http://users2.titanichost.com/lokster/en/vidrop-' & $version & '-install.exe', @ScriptDir & '\update\vidrop-install.exe', 1, 1)
EndFunc   ;==>DownloadUpdate

Func CheckBytesDownloaded()
    If @InetGetActive == 1 Then
        GUICtrlSetData($Button14, Round((@InetGetBytesRead / $update_size) * 100, 1) & ' % свалени')
    Else
        AdlibDisable()
        GUICtrlSetData($Button14, 'Check for update')
        GUICtrlSetState($Button14, $GUI_ENABLE)
        Local $ans = MsgBox(4 + 32, 'Question', 'Update download is done. Do you want to install this update?(Note: The old version of viDrop will be deleted. Press enter in the next window to continue.')
        If $ans == 6 Then
            Run(@ScriptDir & '\uninstall.bat')
            Run(@ScriptDir & '\update\vidrop-install.exe')
            Exit
        EndIf
    EndIf
EndFunc   ;==>CheckBytesDownloaded

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0