Skip to content

Instantly share code, notes, and snippets.

@stylpe
Created December 8, 2011 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stylpe/1448692 to your computer and use it in GitHub Desktop.
Save stylpe/1448692 to your computer and use it in GitHub Desktop.
3DS Video v0.21 with subroutine for file splitting
Gui, Add, Text, x22 y30 w100 h20 , Source Video:
Gui, Add, Text, x22 y60 w100 h20 , Video Folder:
Gui, Add, Edit, x122 y30 w270 h20 vVideoPath,
Gui, Add, Edit, x122 y60 w270 h20 vVideoFolder,
Gui, Add, Button, x395 y30 w100 h20 gSelectVideo, Browse
Gui, Add, Button, x395 y60 w100 h20 gSelectFolder, Browse
Gui, Add, Text, x22 y90 w100 h20 , Video format
Gui, Add, Button, x112 y150 w290 h30 gConvert, Convert
Gui, Add, Text, x22 y120 w100 h20 vQual, Quality
Gui, Add, Edit, x122 y120 w240 h20 vQualEdit,
Gui, Add, UpDown, x362 y120 w20 h20 Range1-31 vQualityUD , UpDown
Gui, Add, Button, x395 y120 w100 h20 gAdvanced, Advanced...
Gui, Add, Text, x22 y120 w60 h20 Hidden vBR, Bitrate
Gui, Add, Edit, x122 y120 w100 h20 Hidden vBitrate,
Gui, Add, Text, x225 y120 w60 h20 Hidden vFP, FPS
Gui, Add, Edit, x292 y120 w100 h20 Hidden vFPS,
Gui, Add, Radio, x122 y90 w70 h20 vTB, Top-bottom
Gui, Add, Radio, x202 y90 w100 h20 vSbS, Side-by-side
Gui, Add, Radio, x312 y90 w100 h20 v2D, 2D
;Gui, Add, Checkbox, x202 y150 w100 h20 vMirror, Mirror Input
; Generated using SmartGUI Creator for SciTE
Gui, Show, w523 h210, 3DS Video v0.21
Advanced := 0
return
GuiClose:
ExitApp
SelectVideo:
FileSelectFile, PathToVideo,,, Select video, *.*
GuiControl,, VideoPath, %PathToVideo%
return
SelectFolder:
FileSelectFolder, PathToFolder,,, Select video folder
GuiControl,, VideoFolder, %PathToFolder%
return
Advanced:
if (Advanced = 0)
{
GuiControl, Hide, QualEdit
GuiControl, Hide, Qual
GuiControl, Hide, QualityUD
GuiControl, show, FP
GuiControl, show, BR
GuiControl, show, Bitrate
GuiControl, show, FPS
Advanced := 1
return
}
if (Advanced = 1)
{
GuiControl, Show, QualEdit
GuiControl, Show, Qual
GuiControl, Show, QualityUD
GuiControl, Hide, FP
GuiControl, Hide, BR
GuiControl, Hide, Bitrate
GuiControl, Hide, FPS
Advanced := 0
return
}
return
Convert:
Gui, submit, NoHide
;do some checks
if !VideoPath
{
MsgBox Error! Select video
return
}
if !VideoFolder
{
MsgBox Error! Select video folder
return
}
if !TB && !SbS && !2D
{
MsgBox Error! Select video format
return
}
;generate file name
Loop
{
FileName := VideoFolder . "\VID_" . SubStr("000" . A_Index,-3) . ".AVI"
IfExist, %FileName%
continue
break
}
;Top-bottom
if TB
{
MsgBox, Converting. Please wait!
if (Advanced = 0)
{
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 400x480 -aspect 2:1 -r 20 -vcodec mjpeg -qscale %QualityUD% -vf crop=480:240:0:0 -acodec libmp3lame -ar 44100 -ab 96k -ac 2 "left.avi",, Hide
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 400x480 -aspect 2:1 -vcodec mjpeg -qscale %QualityUD% -vf crop=400:240:0:240 -an "right.avi",, Hide
}
if (Advanced = 1)
{
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 400x480 -aspect 2:1 -r 20 -vcodec mjpeg -r %FPS% -b:v %Bitrate% -vf crop=480:240:0:0 -acodec libmp3lame -ar 44100 -ab 96k -ac 2 "left.avi",, Hide
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 400x480 -aspect 2:1 -vcodec mjpeg -r %FPS% -b:v %Bitrate% -vf crop=400:240:0:240 -an "right.avi",, Hide
}
RunWait, ffmpeg.exe -y -i "left.avi" -i "right.avi" -vcodec copy -acodec adpcm_ima_wav -ac 2 -vcodec copy -map 0:0 -map 0:1 -map 1:0 "temp.avi",, Hide
Gosub, filesplittingmagic
FileDelete, left.avi
FileDelete, right.avi
FileDelete, temp.avi
MsgBox Done!
}
;Side-by-side
if SbS
{
MsgBox, Converting. Please wait!
if (Advanced = 0)
{
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 800x240 -aspect 2:1 -r 20 -vcodec mjpeg -qscale %QualityUD% -vf crop=400:240:0:0 -acodec libmp3lame -ar 44100 -ab 96k -ac 2 "left.avi",, Hide
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 800x240 -aspect 2:1 -vcodec mjpeg -qscale %QualityUD% -vf crop=400:240:400:0 -an "right.avi",, Hide
}
if (Advanced = 1)
{
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 800x240 -aspect 2:1 -r 20 -vcodec mjpeg -r %FPS% -b:v %Bitrate% -vf crop=400:240:0:0 -acodec libmp3lame -ar 44100 -ab 96k -ac 2 "left.avi",, Hide
RunWait, ffmpeg.exe -y -i "%VideoPath%" -s 800x240 -aspect 2:1 -vcodec mjpeg -r %FPS% -b:v %Bitrate% -vf crop=400:240:400:0 -an "right.avi",, Hide
}
RunWait, ffmpeg.exe -y -i "left.avi" -i "right.avi" -vcodec copy -acodec adpcm_ima_wav -ac 2 -vcodec copy -map 0:0 -map 0:1 -map 1:0 "temp.avi",, Hide
Gosub, filesplittingmagic
FileDelete, left.avi
FileDelete, right.avi
FileDelete, temp.avi
MsgBox Done!
}
;2D
if 2D
{
MsgBox, Converting. Please wait!
if (Advanced = 0)
RunWait, ffmpeg.exe -i "%VideoPath%" -s 400x240 -aspect 2:1 -r 20 -vcodec mjpeg -qscale %QualityUD% -acodec adpcm_ima_wav -ac 2 "temp.avi",, Hide
if (Advanced = 1)
RunWait, ffmpeg.exe -i "%VideoPath%" -s 400x240 -aspect 2:1 -r %FPS% -vcodec mjpeg -b:v %Bitrate% -acodec adpcm_ima_wav -ac 2 "temp.avi",, Hide
Gosub, filesplittingmagic
FileDelete, temp.avi
MsgBox Done!
}
return
filesplittingmagic:
Loop
{
Loop
{
FileName := VideoFolder . "\VID_" . SubStr("000" . A_Index,-3) . ".AVI"
IfExist, %FileName%
continue
break
}
Starttime := (A_Index - 1) * 599
EndTime := 599
RunWait, ffmpeg.exe -i "temp.avi" -vcodec copy -acodec adpcm_ima_wav -ac 2 -ss %StartTime% -t %EndTime% %FileName%,, Hide
FileGetSize, SizeCheck, %FileName%, K
if (SizeCheck < 30)
{
FileDelete, %FileName%
break
}
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment