Advertisement
Najeebsk

FFMPEG-VIDEO-TOOL.ahk

Nov 28th, 2023 (edited)
1,540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Warn
  2. #NoEnv
  3. #SingleInstance, Force
  4. SetWorkingDir %A_ScriptDir%
  5. global winTitle
  6. winTitle := "ahk_class ConsoleWindowClass"
  7. Gui,2: -DPIScale
  8. Gui,2:Font,s12 CYellow,Lucida Console
  9. Gui,2: Color,Black, Black
  10. ;--------------------------
  11. PR=%A_ScriptDir%\APP\ffmpeg.exe
  12. PR2=%A_ScriptDir%\APP\youtube-dl.exe
  13. PR3=%A_ScriptDir%\APP\wget.exe
  14. PR4=%A_ScriptDir%\APP\nircmd.exe
  15. VLC=%A_ProgramFiles%\VideoLAN\VLC\vlc.exe
  16. AA=%A_Desktop%                 ; <<< Browse search fileselectfile from here
  17. ;---------------------------
  18. edcol1=white
  19. btcol =Gray
  20. Gui,2:Add, Edit, x5     y10  w700 h80  c%edcol1% vF1,
  21. ;-- 2 - buttons
  22. Gui,2:Add,Progress,            x720  y10   w150   h27  Disabled Background%btcol%
  23. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gBrowse   ,Browse
  24. ;--------------
  25. Gui,2:Add,Progress,            x720  y60   w150   h27  Disabled Background%btcol%
  26. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvert2 ,Convert MP3
  27. ;--------------
  28. Gui,2:Add,Progress,            x10  y100   w150   h27  Disabled Background%btcol%
  29. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvert1 ,Convert MP4
  30. ;--------------
  31. Gui,2:Add,Progress,            x175  y100   w150   h27  Disabled Background%btcol%
  32. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertD ,DeskTop Record
  33. ;--------------
  34. Gui,2:Add,Progress,            x340  y100   w150   h27  Disabled Background%btcol%
  35. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertS ,Download-M3u8
  36. ;--------------
  37. ;-- CHOOSE EXTRAC VIDEO to PICTURES TIMINGS (if needed)
  38. Gui,2:Add, Text, x500     y106  w55 h30, P-Sec:
  39. Gui, 2:Add, DropDownList, x565 y100 w140  vTP ,-vf fps=1||-r 0.5 -f image2|-r 0.2 -f image2 |-r 0.01979 -f image2
  40. Gui,2:Add,Progress,            x720  y100   w150   h27  Disabled Background%btcol%
  41. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertP ,Extrac-Picture
  42. ;--------------
  43. ;-- CHOOSE VIDEO TIMINGS (if needed)
  44. edcol1=white
  45. btcol =Gray
  46. Gui,2:Add, Text, x10     y156  w110 h30, Start Time:
  47. Gui,2:Add, Edit, x125     y150  w100 h30  c%edcol1% vT1,00:00:00
  48. Gui,2:Add, Text, x230     y156  w100 h30, End Time:
  49. Gui,2:Add, Edit, x330     y150  w100 h30  c%edcol1% vT2,00:00:00
  50. Gui,2:Add, Text, x435     y156  w160 h30, V-Qulity(1-50):
  51. Gui,2:Add, Edit, x600     y150  w90 h30  c%edcol1% vQ,30
  52. Gui,2:Add,Progress,            x720  y150   w150   h27  Disabled Background%btcol%
  53. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertT ,Cut-Video
  54. ;--------------
  55. ;-- CHOOSE YOUTUBE TIMINGS (if needed)
  56. edcol1=white
  57. btcol =Gray
  58. Gui,2:Add, Text, x10     y200  w110 h30, Start Time:
  59. Gui,2:Add, Edit, x125     y200  w100 h30  c%edcol1% vTY1,00:00:00
  60. Gui,2:Add, Text, x230     y200  w100 h30, End Time:
  61. Gui,2:Add, Edit, x330     y200  w100 h30  c%edcol1% vTY2,00:00:00
  62. Gui,2:Add, Text, x435     y200  w160 h30, V-Qulity(18-22):
  63. Gui,2:Add, Edit, x600     y200  w90 h30  c%edcol1% vQY,17
  64. Gui,2:Add,Progress,            x720  y200   w150   h27  Disabled Background%btcol%
  65. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertY ,Cut-YouTube
  66. ;--------------
  67. ;-- CHOOSE OVERLAY VIDEO (if needed)
  68. edcol1=white
  69. btcol =Gray
  70. Gui,2:Add, Edit, x5     y250  w700 h30  c%edcol1% vF3,
  71. Gui,2:Add,Progress,            x720  y250   w150   h27  Disabled Background%btcol%
  72. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gBrowse2   ,Browse
  73. Gui,2:Add, Text, x10     y300  w880 h30, Overlay:10: 10 ,  540: 10 ,  10: 400 ,  540: 400 ...  ,  Scale = 100 , 200 , 250 , 300 , ... Note: Only File.Ext (Video.mp4)
  74. Gui,2:Add, Text, x10     y356  w80 h30, Scale:
  75. Gui,2:Add, Edit, x110     y350  w80 h30  c%edcol1% vSC,100
  76. Gui,2:Add, Text, x230     y356  w100 h30, Overlay:
  77. Gui,2:Add, Edit, x330     y350  w340 h30  c%edcol1% vOV,10: 10
  78. Gui,2:Add,Progress,            x720  y350   w150   h27  Disabled Background%btcol%
  79. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertO ,Overlay Video
  80. ;--------------
  81. ;-- CHOOSE WATERMARK VIDEO (if needed)
  82. Gui,2:Add, Text, x10     y400  w880 h30, WaterMark:25:25 , 10:10 , 540:10 ,  ...  ,  Time To= 0,20 , 10,100 , 50,200  , ... Note: Only File.png ,jpg...
  83. Gui,2:Add, Text, x10     y456  w100 h30, Time To:
  84. Gui,2:Add, Edit, x100     y450  w120 h30  c%edcol1% vPT,0,20
  85. Gui,2:Add, Text, x230     y456  w200 h30, Water Mark Scale:
  86. Gui,2:Add, Edit, x430     y450  w240 h30  c%edcol1% vPV,25:25
  87. Gui,2:Add,Progress,            x720  y450   w150   h27  Disabled Background%btcol%
  88. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertPW ,Water-M-Image
  89. ;--------------
  90. ;-- CHOOSE WATERMARK TEXT VIDEO (if needed)
  91. Gui,2:Add, Text, x10     y500  w880 h30, WaterMark:25:25 , 10:10 , 540:10 ,  ...  ,  Time To= 0,20 , 10,100 , 50,200  , ... Note: Only File.png ,jpg...
  92. Gui,2:Add, Text, x10     y556  w80 h30, FONT:
  93. Gui,2:Add, Edit, x65     y550  w100 h30  c%edcol1% vFON,Ampher.ttf
  94. Gui,2:Add, Text, x170     y556  w200 h30, TEXT:
  95. Gui,2:Add, Edit, x220     y550  w160 h30  c%edcol1% vTEXT,Text Here OR File
  96. Gui,2:Add, Text, x390     y556  w200 h30, FColor:
  97. Gui,2:Add, Edit, x460     y550  w60 h30  c%edcol1% vFONC,Red
  98. Gui,2:Add, Text, x528     y556  w200 h30, FSize:
  99. Gui,2:Add, Edit, x590     y550  w40 h30  c%edcol1% vFONS,24
  100. Gui,2:Add, Text, x636     y556  w200 h30, X:
  101. Gui,2:Add, Edit, x660     y550  w40 h30  c%edcol1% vX,10
  102. Gui,2:Add, Text, x705     y556  w200 h30, Y:
  103. Gui,2:Add, Edit, x730     y550  w40 h30  c%edcol1% vY,10
  104. Gui,2:Add,Progress,            x790  y550   w80   h27  Disabled Background%btcol%
  105. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gConvertTW ,V-Text
  106. ;--------------
  107. ;--------------------------
  108. Extensions1 := "mp3,m4a,wav,wma,flv,vob,mp4,mpg,wmv,avi,aiff,jpg,png,bmp,tif,gif,css,pdf,zip,rar,tar,vbs,ahk,au3,m3u,m3u8,txt,reg"   ;- search url this extension
  109. ;f1=http://nwhiker.com/wallpaper/                   ;- url which contains music files
  110. fd=%A_ScriptDir%\My-Downloads                                       ;- where to download
  111. f2=%fd%\My-Doc.txt                                          ;- if wanted write url from each music to a file
  112. ifnotexist,%fd%                                                 ;- create folder
  113.    filecreatedir,%fd%
  114. ifexist,%f2%                                                    ;- delete text-file if exists
  115.    filedelete,%f2%
  116. ;--------------
  117. Gui,2:Add, Text, x10     y606  w75 h30, YOUTUBE:
  118. Gui, 2:Add, DropDownList, x90 y600 w120  vYG ,-a D.txt||-x|-F |-f 17|-f 18|-f 22|best|bestvideo|bestaudio|worstvideo
  119. Gui,2:Add,Progress,            x220  y600   w150   h27  Disabled Background%btcol%
  120. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gYTDL ,YOUTUBE
  121. ;--------------
  122. Gui,2:Add,Progress,            x385  y600   w150   h27  Disabled Background%btcol%
  123. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gDOWN ,ALL-DOWNLAOD
  124. ;--------------
  125. Gui,2:Add, Text, x550     y606  w55 h30, WGET:
  126. Gui, 2:Add, DropDownList, x600 y600 w110  vWG ,-i D.txt||-c |-m |-r|
  127. Gui,2:Add,Progress,            x720  y600   w150   h27  Disabled Background%btcol%
  128. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gWGET ,WGET
  129. ;--------------
  130. Gui,2:Add, Text, x10     y656  w200 h30, LOOP:
  131. Gui,2:Add, Edit, x60     y650  w40 h30  c%edcol1% vLOP,10
  132. Gui,2:Add, Text, x110     y656  w110 h30, PER SEC:
  133. Gui,2:Add, Edit, x190     y650  w100 h30  c%edcol1% vSEC2,60000
  134. Gui,2:Add,Progress,            x300  y650   w150   h27  Disabled Background%btcol%
  135. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gSCR ,SCREENSHOT
  136. ;----------------------
  137. Gui,2:Add,Progress,            x460  y650   w150   h27  Disabled Background%btcol%
  138. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gVL ,IPTV-PLAYER
  139. ;----------------------
  140. Gui,2:Add,Progress,            x620  y650   w160   h27  Disabled Background%btcol%
  141. Gui,2:Add,Text,                xp    yp     wp    hp   cYellow  BackgroundTrans center 0x200 gCM ,EXECUTE COMMAND
  142. ;--------------
  143. GUI,2:show, NA x20 y20 W900 h700, Drag & Drop or Browse for Video-files / Najeeb Converter And Video Cutter And Downlaoder And Record DeskTop
  144. return
  145. ;----------------------------------------------------------
  146. 2GuiDropFiles:
  147. Loop, parse, A_GuiEvent, `n
  148.    GuiControl,2:,F1,%A_LoopField%
  149. return
  150. ;----------------------------------------------------------
  151. 2GuiClose:
  152. ExitApp
  153. ;----------------------------------------------------------
  154. Browse:
  155. FileSelectFile, filename,1,%aa%,Select your file,*.flv;*.mpg;*.webm;*.3gp;*avi;*.vob;*.mov;*.wmv;*.mp4;*.m4a;*.mkv
  156. if filename =
  157.    return
  158. GuiControl,2:,F1,%filename%
  159. return
  160. Browse2:
  161. FileSelectFile, filename,1,%aa%,Select your file,*.flv;*.mpg;*.webm;*.3gp;*avi;*.vob;*.mov;*.wmv;*.mp4;*.m4a;*.mkv
  162. if filename =
  163.    return
  164. GuiControl,2:,F3,%filename%
  165. return
  166. ;-------------------------------
  167. Convert2:
  168. Gui,2:submit,nohide
  169. SplitPath,F1,name, dir, ext, name_no_ext, drive
  170. Filedest=%A_ScriptDir%\Downloads\ %name_no_ext%.mp3
  171. if (ext="mp4" or ext="flv" or ext="mpg" or ext="webm" or ext="3gp" or ext="avi" or ext="vob" or ext="m4a" or ext="mov" or ext="wmv" or ext="mkv")
  172.    {
  173.    runwait,%comspec% /k %pr% -i "%f1%" -acodec libshine "%Filedest%"
  174.   ; run,%filedest%
  175.    }
  176. else
  177.   msgbox, 262208, ,Not a desired video-extension  found
  178. return
  179. ;-------------------------------
  180. Convert1:
  181. Gui,2:submit,nohide
  182. SplitPath,F1,name, dir, ext, name_no_ext, drive
  183. Filedest=%A_ScriptDir%\Downloads\ %name_no_ext%.mp4
  184. if (ext="mp4" or ext="flv" or ext="mpg" or ext="webm" or ext="3gp" or ext="avi" or ext="vob" or ext="m4a" or ext="mov" or ext="wmv" or ext="mkv")
  185.    {
  186.    runwait,%comspec% /k %pr% -i "%f1%" -c:v copy -c:a copy -y "%Filedest%"
  187.   ; run,%filedest%
  188.    }
  189. else
  190.   msgbox, 262208, ,Not a desired video-extension  found
  191. return
  192. ;-------------------------------
  193. ConvertD:
  194. Gui,2:submit,nohide
  195.    {
  196.    runwait,%comspec% /k %pr% -f gdigrab -framerate 30 -i desktop "%A_ScriptDir%\Downloads\DESKTOP-RECORD.mp4"
  197.   ; run,%filedest%
  198.    }
  199. return
  200. ;-------------------------------
  201. ConvertS:
  202. Gui,2:submit,nohide
  203.  
  204. {
  205.    runwait,%comspec% /k %pr% -i "%f1%" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf  18  "%A_ScriptDir%\Downloads\Stream.mp4"
  206.   ; run,%filedest%
  207.    }
  208. return
  209. ;-------------------------------
  210. ConvertT:
  211. Gui,2:submit,nohide
  212.  
  213. {
  214.    runwait,%comspec% /k %pr% -i "%f1%" -ss %T1% -to %T2%  -bsf:a aac_adtstoasc -vcodec copy -c copy -crf  %Q% "%A_ScriptDir%\Downloads\V-CUT.mp4"
  215.   ; run,%filedest%
  216.    }
  217. return
  218. ;-------------------------------
  219. ConvertY:
  220. Gui,2:submit,nohide
  221.  
  222. {
  223.    runwait,%comspec% /k %pr2% "%f1%" --external-downloader ffmpeg --external-downloader-args "-ss %TY1% -to %TY2%" -f %QY% "%A_ScriptDir%\Downloads\V-CUT.mp4"
  224.   ; run,%filedest%
  225.    }
  226. return
  227. ;-------------------------------
  228. ConvertO:
  229. Gui,2:submit,nohide
  230.   ; runwait,%comspec% /k %pr% -i %f1% -vf  "movie=%f3%, scale=%sc%: -1 [inner]; [in][inner] overlay =%ov%[out] C:\Users\Najeeb\Desktop\Downloads\Video-Overlay.mp4"
  231.   ; run,%filedest%
  232. run cmd.exe
  233. WinWait, ahk_exe cmd.exe
  234. Send %pr% -i %f1% -vf  "movie=%f3%, scale=%sc%: -1 [inner]; [in][inner] overlay =%ov% [out]" "Downloads\OUTPUT.mp4"{Enter}
  235.  
  236. return
  237. ;-------------------------------
  238. ConvertP:
  239. Gui,2:submit,nohide
  240.   ; runwait,%comspec% /k %pr% -i %f1% -vf  "movie=%f3%, scale=%sc%: -1 [inner]; [in][inner] overlay =%ov%[out] C:\Users\Najeeb\Desktop\Downloads\Video-Overlay.mp4"
  241.   ; run,%filedest%
  242. run cmd.exe
  243. WinWait, ahk_exe cmd.exe
  244. Send APP\ffmpeg.exe -i %f1% %tp% "Downloads\OUT-{asc 0037}d.jpg"{Enter}
  245. return
  246. ;-------------------------------
  247. ConvertPW:
  248. Gui,2:submit,nohide
  249.   ; runwait,%comspec% /k %pr% -i "%f1%" -i "%f3%" -filter_complex "[0:v][1:v] overlay=%pv%:enable='between(t,%pt%)'" -pix_fmt yuv420p -c:a copy "%A_ScriptDir%\Downloads\V-CUT.mp4"
  250.   ; run,%filedest%
  251. run cmd.exe
  252. WinWait, ahk_exe cmd.exe
  253. Send APP\ffmpeg.exe -i "%f1%" -i "%f3%" -filter_complex "[0:v][1:v] overlay=%pv%:enable='between(t,%pt%)'" -pix_fmt yuv420p -c:a copy "Downloads\Water-Mark-PIC.mp4"{Enter}
  254. return
  255. ;-------------------------------
  256. ConvertTW:
  257. Gui,2:submit,nohide
  258.   ; runwait,%comspec% /k %pr% -i "%f1%" -i "%f3%" -filter_complex "[0:v][1:v] overlay=%pv%:enable='between(t,%pt%)'" -pix_fmt yuv420p -c:a copy "%A_ScriptDir%\Downloads\V-CUT.mp4"
  259.   ; run,%filedest%
  260. run cmd.exe
  261. WinWait, ahk_exe cmd.exe
  262. Send APP\ffmpeg.exe -i %f1% -vf  drawtext=fontfile=font\%fon%:text=%text%:fontcolor=%fonc%:fontsize=%fons%:x=%x%:y=%y% "Downloads\Text-Video.mp4"{Enter}
  263. return
  264. ;------------------------------------------
  265. DOWN:
  266. Gui,2:submit,nohide
  267. allx=
  268. httpQuery(allx,F1)                                              ;- download url ( f1 ) to a variable ( allx )
  269. res=
  270. total1=0
  271. while pos := RegExMatch(allx, "<a href=.*?(?=(\\|&|>))", m, A_Index=1?1:pos+StrLen(m))  ;- search lines with url's in webpage ( F1 )
  272.         {
  273.         stringreplace,m,m,<a href=",,all     ;- remove <a href="
  274.         stringreplace,m,m,",,all             ;- remove "
  275.         new=%f1%%m%                          ;- URL found in F1
  276.         SplitPath,new, name, dir, ext, name_no_ext, drive
  277.         if ext in %Extensions1%              ;- only url's which desired extension
  278.             {
  279.             total1++
  280.             res .= new "`r`n"                ;- add each found line to variable RES and add EndOfLine ASCII 13/10
  281.             }
  282.         }
  283. msgbox,%res%                                  ;- show found url's
  284. i=0
  285. if res<>                    ;- if variable RES is not empty
  286.   {
  287.   fileappend,%res%,%f2%    ;- create a textfile if needed , write variable RES to a file
  288.   fileread,RES,%f2%        ;- this woul'd read the text-file (F2) if you haven't variable RES yet <<< READ a TEXT-FILE
  289.   Loop,parse,res,`n,`r      ;- read variable RES with the url's
  290.     {
  291.     i++
  292.     T=%A_LoopField%         ;- read each line and then download it ( splashimage is only like a message-box to see what happens )
  293.     SplitPath,t, name, dir, ext, name_no_ext, drive
  294.     Splashimage,,w600 x10 y130 C01 CWsilver FS10 ZH0 M2,Download I=%i%  /  Total=%total1% files,Now downloading=`n%name%`nTO DESKTOP`n%fd%,Escape to break,Lucida Console
  295.     urldownloadtofile,%t%,%fd%\%name%
  296.     Splashimage,off
  297.     }
  298.   ifexist,%fd%
  299.       run,%fd%          ;- open folder when download is finished
  300.   ;run,%f2%             ;- open text-file
  301.   }
  302. res=                     ;- clear variable  RES
  303. allx=                    ;- clear variable  allx
  304. httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")
  305. {
  306.    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  307.    WebRequest.Open("GET", lpszUrl)
  308.    WebRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
  309.    WebRequest.Send(POSTDATA)
  310.    Result := WebRequest.ResponseText
  311.    WebRequest := ""
  312. }
  313. return
  314. ;-------------------------------
  315. Stop(CtrlHwnd, GuiEvent, EventInfo, ErrLevel := "") {
  316.    msgbox "This should stop it if winTitle exists"
  317. if WinExist(winTitle)
  318.     {
  319.     msgbox "winTitle Found"
  320.     WinActivate
  321.     Send q
  322.     WinWaitClose
  323.     Run % out
  324.     }
  325. }
  326. ;------------------------------------------
  327. YTDL:
  328. Gui,2:submit,nohide
  329. {
  330.    runwait,%comspec% /k %pr2% "%f1%" %yg%
  331.   ; run,%filedest%
  332.    }
  333. return
  334. ;------------------------------------------
  335. WGET:
  336. Gui,2:submit,nohide
  337. {
  338.    runwait,%comspec% /k %pr3% "%f1%" %wg% -P "Downloads/"
  339.   ; run,%filedest%
  340.    }
  341. return
  342. ;------------------------------------------
  343. SCR:
  344. Gui,2:submit,nohide
  345. {
  346.    runwait,%comspec% /k %pr4% loop %lop% %sec2% savescreenshot "~$folder.nircmd$\My-PICTURES\P~$loopcount$.png"
  347.    ; run,%filedest%
  348.    }
  349. return
  350. ;------------------------------------------
  351. VL:
  352. Gui,2:submit,nohide
  353. {
  354.   Run, %vlc%  %f1%
  355.    ; run,%filedest%
  356.    }
  357. return
  358. ;------------------------------------------
  359. CM:
  360. Gui,2:submit,nohide
  361. {
  362.   Run, "%A_ScriptDir%\COMMANDER.ahk"
  363.    ; run,%filedest%
  364.    }
  365. return
  366. ;============ END SCRIPT ==============
  367. #R::Reload
  368. #S::Suspend
  369. #P::Pause
  370. #ESC::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement