Advertisement
Guest User

Havenard

a guest
Aug 20th, 2009
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Set oFSO   = CreateObject("Scripting.FileSystemObject")
  3. Set WShell = CreateObject("WScript.Shell")
  4.  
  5. Set oFil = oFSO.CreateTextFile("script.bat", True)
  6.  
  7. oFil.WriteLine "@echo off"
  8.  
  9. Function ToNumTime(S)
  10.             T = CInt(Mid(S, 1, 2)) * 3600000
  11.             T = T + CInt(Mid(S, 4, 2)) * 60000
  12.             T = T + CInt(Mid(S, 7, 2)) * 1000
  13.             T = T + CInt(Mid(S, 10)) * 10 ^ (3 - Len(Mid(Line, 10)))
  14.             T = T / 1000
  15.             ToNumTime = T
  16. End Function
  17.  
  18. Function FromNumTime(T)
  19.             S = Mid(CStr(Round(T - Int(T), 3)), 3)
  20.             While Len(S) < 3 : S = S & "0" : Wend
  21.             S = CStr(Int(T) Mod 60) & "." & S
  22.             While Len(S) < 6 : S = "0" & S : Wend
  23.             S = CStr((T \ 60) Mod 60) & ":" & S
  24.             While Len(S) < 9 : S = "0" & S : Wend
  25.             S = CStr(T \ 3600) & ":" & S
  26.             While Len(S) < 12 : S = "0" & S : Wend
  27.             FromNumTime = S
  28. End Function
  29.  
  30. Sub PrepareVideo(FileName)
  31.     Set oProc = WShell.Exec("ffmpeg.exe -i ""..\new_raw_videos\" & FileName & """")
  32.     Set oStdOut = oProc.StdErr
  33.  
  34.     While Not oStdOut.AtEndOfStream
  35.         Line = oStdOut.ReadLine
  36.         If Left(Line, 12) = "  Duration: " Then
  37.             T = ToNumTime(Mid(Line, 13, InStr(Line, ",") -13))
  38.             While Not oStdOut.AtEndOfStream : Line = oStdOut.ReadLine : Wend
  39.           oFil.WriteLine "ffmpeg.exe -y -i ""..\new_raw_videos\" & FileName & """ -ar 22050 -ac 1 -ab 56k -f flv -s 320x240 -b 256k -r 15 -acodec mp3 ""%TEMP%\" & FileName & ".flv"""
  40.             oFil.WriteLine "ffmpeg.exe -y -i ""..\new_raw_videos\" & FileName & """ -f mjpeg -ss " & FromNumTime(T * 0.50) & " -vframes 1 -s 128x96 -an ""%TEMP%\thumb_" & FileName & ".jpg"""
  41.             oFil.WriteLine "ffmpeg.exe -y -i ""..\new_raw_videos\" & FileName & """ -f mjpeg -ss " & FromNumTime(T * 0.50) & " -vframes 1 -s 320x240 -an ""%TEMP%\" & FileName & ".jpg"""
  42.           oFil.WriteLine "move ""%TEMP%\" & FileName & ".flv"" ""..\public_html\new_videos\" & FileName & ".flv"""
  43.             oFil.WriteLine "move ""%TEMP%\" & FileName & ".jpg"" ""..\public_html\new_videos\" & FileName & ".jpg"""
  44.             oFil.WriteLine "move ""%TEMP%\thumb_" & FileName & ".jpg"" ""..\public_html\new_videos\thumb_" & FileName & ".jpg"""
  45.         End If
  46.     Wend
  47. End Sub
  48.  
  49. Set oFol = oFSO.GetFolder("..\new_raw_videos\")
  50.  
  51. For Each oFile in oFol.Files
  52.     If (Right(oFile.Name, 4) <> ".lnk") Then
  53.         PrepareVideo oFile.name
  54.     End If
  55. Next
  56.  
  57. oFil.WriteLine "start ..\public_html\new_videos\"
  58. oFil.WriteLine "del script.bat"
  59.  
  60. oFil.Close
  61.  
  62. WShell.Run "script.bat"
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement