Hi
Ist etwas grob zusammengezimmert:
Spoiler anzeigen
#include <GUIConstants.au3>
#include <inet.au3>
#include <Date.au3>
GUICreate("You Tube Video-Downloader", 273, 105, 193, 115, -1)
$DwnInput = GUICtrlCreateInput("Hier YouTube Link Rein !", 8, 24, 257, 21)
GUICtrlCreateLabel("www.youtube.com Download Link:", 8, 8, 268, 15)
$start = GUICtrlCreateButton("&Start", 8, 48, 128, 25, 0)
$Progress = GUICtrlCreateProgress(8, 80, 257, 16)
$abb = GUICtrlCreateButton("A&bbruch", 137, 48, 128, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $start
GUICtrlSetState($start,$GUI_DISABLE)
$dwnlink = GUICtrlRead($DwnInput)
$sCode=_INetGetSource ($dwnlink)
$s_t=StringRegExp($sCode, "&t=(.*?)&", 3)
$s_v=stringmid($dwnlink,stringinstr($dwnlink,"v=")+2)
$save = FileSaveDialog("Speichere FLV","","Flash Video(*.flv)",-1,$s_v)
If StringRight($save,4) <> ".swf" Then $save&=".flv"
_Download("http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t[0],$save,$Progress)
GUIDelete()
MsgBox(0,"","Fertig!")
Exit
EndSwitch
WEnd
Func _Download($site,$punkt,$prog=0)
$orisize = InetGetSize($site)
InetGet($site,$punkt,1,1)
If $prog = 0 Then ProgressOn("Download","")
Do
$msg = GUIGetMsg()
If $msg = $abb Then
If MsgBox(4,"","Abbruch?") = 6 Then Exit
EndIf
$size1 = FileGetSize($punkt)
$MBsize1 = FileGetSize($punkt)
$inetget = @InetGetBytesRead
$Prozent = (100 * $inetget ) / $orisize
$decimalplace = Round ($Prozent)
$decimalplaceMBsize1 = Round (@InetGetBytesRead / 1024)
If $prog = 0 Then
ProgressSet ($Prozent, $decimalplace & "% " & "(" & $decimalplaceMBsize1 & ") Kb sind bereits gedownloadet.")
Else
GUICtrlSetData($prog,$Prozent)
EndIf
Until @InetGetActive = 0
If $prog = 0 Then ProgressOff ()
Local $sFFmpeg="", $hFFmpeg
$hFFmpeg=Run(@ScriptDir & '\ffmpeg.exe -i "' & $punkt & '" -y "' & StringTrimRight($punkt,3) & 'avi"',@ScriptDir,@SW_HIDE,0x4)
While 1
$sFFmpeg &= StderrRead($hFFmpeg)
If @error Or StringInStr($sFFmpeg,"Duration") Then ExitLoop
WEnd
$sFFmpeg = StringLeft(StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "Duration:") + 9),
$iTicks = _TimeToTicks(StringLeft($sFFmpeg, 2), StringMid($sFFmpeg, 4, 2), StringMid($sFFmpeg, 7, 2))
While 1
$sFFmpeg = StderrRead($hFFmpeg)
If @error Then ExitLoop
If StringInStr($sFFmpeg,"time=") Then
$sFFmpeg=StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "time=") + 4)
GUICtrlSetData($prog,(StringLeft($sFFmpeg, StringInStr($sFFmpeg, ".")-1) *100000)/$iTicks)
EndIf
WEnd
Return $punkt
EndFunc
Das konvertierte Video ist noch kein "reines" Avi, sondern ein mp4-Codec
Du kannst noch mit -vcodec einen anderen Videocodec auswählen...
Infos hierzu: ffmpeg.exe -h bzw. ffmpeg.exe -formats
ffmpeg.exe gibts hier:
http://www.videohelp.com/download/ffmpeg-0.5.7z
lgE