#module aviwave
#uselib "avifil32.dll"
#func AVIFileInit "AVIFileInit"
#cfunc AVISaveOptions "AVISaveOptions" int, int, int, var, var
#cfunc AVISaveV "AVISaveV" str, int, int, int, var, var
#func AVISaveOptionsFree "AVISaveOptionsFree" int, var
#cfunc AVIStreamOpenFromFile "AVIStreamOpenFromFile" var, str, int, int, int, int
#func AVIFileOpen "AVIFileOpen" var, str, int, nullptr;int
#func AVIFileGetStream "AVIFileGetStream" int, var, int, int
#func AVIFileRelease "AVIFileRelease" int
#func AVIStreamRelease "AVIStreamRelease" int
#func AVIFileExit "AVIFileExit"
#defcfunc _SaveAviFile str resfname, int havi, int hwav
/*repeat 2
ZeroMemory(&options[i], sizeof(AVICOMPRESSOPTIONS));
lpOptions(cnt) = &options[i];
wait 0
loop*/
pavis = havi, hwav
dim x, 2
/*dim lpOptions, 44, 2
if optdlg {
sores = AVISaveOptions(hwnd, 0, 2, pavis, lpOptions)
if sores != 0 & sores != 1 : return 1
if sores = 0 : x = 0, 0 : else {
x(0) = lpOptions(0)
x(1) = lpOptions(1)
}
} else : */x = 0, 0
code = 0
if AVISaveV(resfname, 0, 0, 2, pavis, x) : code = 2
;if sores = 1 : AVISaveOptionsFree 2, lpOptions
return code
#defcfunc _GetAudioFromAVI str wavifn
AVIFileOpen audavi, wavifn, 0;, 0
if stat != 0 : return -3
AVIFileGetStream audavi, hwave, 1935963489, 0
code = stat
AVIFileRelease audavi
if code : return -4
return hwave
#deffunc AddSoundToAVI str avifn, str _wavfn, str resfn
wavfn = _wavfn
AVIFileInit
if AVIStreamOpenFromFile(aviVideo, avifn, 1935960438, 0, 0, 0) {
AVIFileExit
return -1
}
if getpath(wavfn, 18) == ".avi" {
aviAudio = _GetAudioFromAVI(wavfn)
if aviAudio < 0 : return aviAudio
} else : if getpath(wavfn, 18) == ".wav" {
if AVIStreamOpenFromFile(aviAudio, wavfn, 1935963489, 0, 0, 0) {
AVIStreamRelease aviVideo
AVIFileExit
return -2
}
} else {
AVIStreamRelease aviVideo
AVIFileExit
return -5
}
ret = _SaveAviFile(resfn, aviVideo, aviAudio)
AVIStreamRelease aviAudio
AVIStreamRelease aviVideo
AVIFileExit
return ret
#global
使い方:以下で 動画+音声.avi を出力します
AddSoundToAVI "動画のみ.avi", "音声.wav", "動画+音声.avi"
大分前に作ったものなので正常に動作するかは確認できていません