-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,834 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.7z | ||
*.g.wxs | ||
FFMPEG/ | ||
*.wixobj | ||
*.wixpdb | ||
*.msi | ||
*.png | ||
cabinets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | ||
|
||
<Product Id="*" Name="FFmpeg" Language="1033" Version="5.0.0" Manufacturer="Dunkyl 🔣🔣" UpgradeCode="3a567af2-24ac-410e-9066-5e9278944025" Codepage="UTF-8"> | ||
|
||
<Package InstallerVersion="200" Compressed="yes" /> | ||
|
||
<Condition Message="You need to be an administrator to install this product."> | ||
Privileged | ||
</Condition> | ||
|
||
<Media Id='1' Cabinet='ffmpeg.cab' EmbedCab='yes' /> <!-- DiskPrompt='CD-ROM #1' --> | ||
|
||
<Directory Id='TARGETDIR' Name='SourceDir'> | ||
|
||
<Directory Id='ProgramFiles64Folder' Name='PFiles'> | ||
<Directory Id='INSTALLDIR' Name='FFmpeg'> | ||
<Component Id="UpdatePath" Guid='53269529-139a-4856-9506-199377827ced'> | ||
<CreateFolder /> | ||
<Environment | ||
Id="UpdatePath" | ||
Name="PATH" | ||
Value="[INSTALLDIR]\bin" | ||
Part="last" | ||
Action="set" | ||
System="yes"/> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
|
||
|
||
<Directory Id="DesktopFolder" Name="Desktop" /> | ||
<Directory Id="ProgramMenuFolder"> | ||
<Directory Id="ProgramMenuDir" Name="FFmpeg"> | ||
<Component Id="StartMenuManual" Guid='54ac269d-bce0-434d-876c-4070ee2e041a'> | ||
<RemoveFolder Id='ProgramMenuDir' On='uninstall' /> | ||
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' /> | ||
<Shortcut | ||
Id="ManualShortcut" | ||
Directory="ProgramMenuDir" | ||
Target="[INSTALLDIR]\doc\ffmpeg.html" | ||
Name="FFmpeg Documentation" | ||
WorkingDirectory="INSTALLDIR" > | ||
</Shortcut> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
|
||
|
||
</Directory> | ||
|
||
|
||
<Feature Id="Complete" Title='FFmpeg' Description='The complete package.' | ||
Display='collapse' Level="1" ConfigurableDirectory='INSTALLDIR'> | ||
|
||
<Feature Id="Core" Title='Core' Level="1" > | ||
<ComponentGroupRef Id="FFMPEGbin"/> | ||
<ComponentGroupRef Id="FFMPEGreadme"/> | ||
<ComponentGroupRef Id="FFMPEGlicense"/> | ||
<Feature Id="AddToPath" Title='Add to PATH' Level="1"> | ||
<ComponentRef Id="UpdatePath"/> | ||
</Feature> | ||
</Feature> | ||
|
||
<Feature Id="Manual" Title='Documentation' Level="1" > | ||
<ComponentGroupRef Id="FFMPEGdoc"/> | ||
<ComponentRef Id='StartMenuManual'/> | ||
</Feature> | ||
|
||
<Feature Id="Presets" Title='Presets' Level="1" > | ||
<ComponentGroupRef Id="FFMPEGpresets"/> | ||
</Feature> | ||
</Feature> | ||
|
||
<Icon Id="icon.ico" SourceFile="icon.ico"/> | ||
<Property Id="ARPPRODUCTICON" Value="icon.ico" /> | ||
<WixVariable Id="WixUILicenseRtf" Value="gplv3.rtf" /> | ||
<WixVariable Id="WixUIBannerBmp" Value="banner.bmp" /> | ||
<WixVariable Id="WixUIDialogBmp" Value="dialog.bmp" /> | ||
<!-- <WixVariable Id="WixUIExclamationIco" Value="path\exclamation.ico" /> | ||
<WixVariable Id="WixUIInfoIco" Value="path\information.ico" /> | ||
<WixVariable Id="WixUINewIco" Value="path\new.ico" /> | ||
<WixVariable Id="WixUIUpIco" Value="path\up.ico" /> --> | ||
|
||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> | ||
<UIRef Id="WixUI_InstallDir" /> | ||
<!-- <UIRef Id="WixUI_Mondo" /> --> | ||
|
||
|
||
</Product> | ||
</Wix> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# FFMPEG-Installer | ||
Windows installer to add FFMPEG and a path entry to your system. | ||
|
||
Windows installer to add [FFmpeg](https://ffmpeg.org/) and a path entry to your system. | ||
|
||
Note: FFmpeg is licensed separately from this source code. I am not the owner or maintainer of FFmpeg, credit for that goes to the open source contributors to the FFmpeg project. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
open System | ||
open System.Diagnostics | ||
open System.IO | ||
open System.Net.Http | ||
open System.IO.Compression | ||
|
||
let httpClient = new HttpClient() | ||
|
||
let filenameOf (path: string) = | ||
let uri = Uri path | ||
Path.GetFileName uri.LocalPath | ||
|
||
let download (path: string) = task { | ||
let filename = filenameOf path | ||
|
||
let! r = httpClient.GetAsync path | ||
|
||
use outfile = File.OpenWrite filename | ||
do! r.Content.CopyToAsync outfile | ||
} | ||
|
||
let run processName args = | ||
let p = new ProcessStartInfo ( | ||
FileName = processName, | ||
Arguments = args, | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
CreateNoWindow = true | ||
) | ||
let proc = Process.Start p | ||
let stdout = proc.StandardOutput.ReadToEnd () | ||
let stderr = proc.StandardError.ReadToEnd () | ||
proc.WaitForExit () | ||
|
||
if proc.ExitCode <> 0 then | ||
printfn $"Error running {processName}:\n{stdout}\n{stderr}" | ||
exit proc.ExitCode | ||
|
||
let un7z (path: string) (outpath: string) = | ||
// use reader = new ArchiveReader(path) | ||
// let progress = new Progress<Report>(fun f -> printfn $"{f}%%") | ||
// reader.Save(Path.GetDirectoryName path, progress); | ||
run "7z" $"x -y -spe -o{outpath} {path} " | ||
|
||
let rm path = | ||
if File.Exists path then | ||
File.Delete path | ||
else if Directory.Exists path then | ||
Directory.Delete path | ||
else | ||
printfn $"{path} does not exist" | ||
|
||
let args = System.Environment.GetCommandLineArgs () | ||
|
||
let fetchFFMPEG () = task { | ||
let! res_ver = httpClient.GetAsync "https://www.gyan.dev/ffmpeg/builds/release-version" | ||
let! releaseVer = res_ver.Content.ReadAsStringAsync() | ||
|
||
let releaseURL = $"https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z" | ||
|
||
let! res_sha = httpClient.GetAsync $"{releaseURL}.sha256" | ||
let! sha = res_sha.Content.ReadAsStringAsync() | ||
|
||
let zipFileName = filenameOf releaseURL | ||
|
||
if File.Exists zipFileName then | ||
printfn " Found existing release." | ||
else | ||
printfn " Downloading release..." | ||
do! download releaseURL | ||
printfn " Downloaded release." | ||
|
||
// checksum | ||
let sha_downloaded = | ||
//run "sha256sum" zipFileName | ||
let sha256 = System.Security.Cryptography.SHA256.Create() | ||
let hash = sha256.ComputeHash(File.ReadAllBytes(zipFileName)) | ||
let hash_str = BitConverter.ToString(hash) | ||
hash_str.Replace("-", "").ToLower() | ||
|
||
if sha <> sha_downloaded then | ||
printfn $" SHA mismatch:\nClaimed: {sha}\nActual: {sha_downloaded}" | ||
exit 1 | ||
else | ||
printfn " SHA match" | ||
|
||
let destination = "FFMPEG" | ||
if Directory.Exists destination then | ||
printfn " Already unpacked." | ||
else | ||
printfn " Unpacking release..." | ||
|
||
un7z zipFileName "." | ||
|
||
printfn " Unpacked release." | ||
|
||
// rename to folder without version | ||
Directory.Move($"ffmpeg-{releaseVer}-full_build", "FFMPEG") | ||
|
||
} | ||
|
||
printfn "Fetching latest release:" | ||
fetchFFMPEG() |> Async.AwaitTask |> Async.RunSynchronously | ||
|
||
let heat s = run "heat" s | ||
|
||
let candle s = run "candle" s | ||
|
||
let light s = run "light" s | ||
|
||
let startTime = DateTime.Now | ||
|
||
let genComponents = [ | ||
"FFMPEGbin", "FFMPEG/bin" | ||
"FFMPEGlicense", "FFMPEG/LICENSE" | ||
"FFMPEGreadme", "FFMPEG/README.txt" | ||
"FFMPEGdoc", "FFMPEG/doc" | ||
"FFMPEGpresets", "FFMPEG/presets" | ||
] | ||
printfn "Generating components..." | ||
|
||
for componentId, path in genComponents do | ||
let type', maybe_srd, sourceDirName = | ||
if File.Exists path then | ||
printfn $" file: ./{path} -> {componentId}" | ||
"file", "-srd", path.Split('/')[0] | ||
else | ||
printfn $" directory: ./{path}/* -> {componentId}" | ||
"dir", "", path | ||
// nologo: this is automated | ||
// srd: for files, do not nest the FFMPEG/ directory into INSTALLDIR | ||
// sreg: do not harvest registry info from the EXE's | ||
// sfrag: no need for separate fragments in these components | ||
// gg: i dont care what the GUID's are (at least, at the moment) | ||
// dr: put these in the FFMPEG/ directory | ||
heat $"{type'} {path} -nologo {maybe_srd} -sreg -sfrag -gg -dr INSTALLDIR -cg {componentId} -out {componentId.ToLower()}.g.wxs" | ||
|
||
// work around for correcting the Source path for files | ||
// just a find and replace for 'SourceDir' | ||
use f = File.OpenText $"{componentId.ToLower()}.g.wxs" | ||
let newText = f.ReadToEnd().Replace("SourceDir", $"SourceDir/{sourceDirName}") | ||
f.Close() | ||
|
||
use f = File.CreateText $"{componentId.ToLower()}.g.wxs" | ||
f.Write newText | ||
|
||
|
||
let product = "FFmpeg" | ||
|
||
printfn "Candle..." | ||
|
||
let genScripts = | ||
Directory.EnumerateFiles "." | ||
|> Seq.filter (fun s -> s.EndsWith ".g.wxs") | ||
|> List.ofSeq | ||
|
||
let genScriptsStr = String.Join(" ", genScripts) | ||
|
||
candle $"""-arch x64 {product}.wxs {genScriptsStr}""" | ||
|
||
let elapsedCandle = DateTime.Now - startTime | ||
|
||
printfn $"Candle completed in {elapsedCandle.TotalSeconds:N2} seconds" | ||
|
||
let genObjs = | ||
Directory.EnumerateFiles "." | ||
|> Seq.filter (fun s -> s.EndsWith ".wixobj") | ||
|> List.ofSeq | ||
|
||
let genObjsStr = String.Join(" ", genObjs) | ||
|
||
// genObjsStr includes the product.wixobj | ||
// -b FFMPEG -b FFMPEG/bin -b FFMPEG/presets -b FFMPEG/doc | ||
light $"-ext WixUIExtension -reusecab -cc cabinets -cultures:en-us -loc en-us.wxl -o {product}.msi {genObjsStr} " | ||
|
||
// remove generated files | ||
if not (Array.contains "--keep-generated" args) then | ||
List.append genScripts genObjs | ||
|> List.map rm | ||
|> ignore | ||
|
||
let elapsedLight = DateTime.Now - startTime - elapsedCandle | ||
|
||
printfn $"Done. Elapsed time: {(elapsedCandle + elapsedLight).TotalSeconds:N2} seconds" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<WixLocalization Culture="en-us" Codepage="UTF-8" xmlns="http://schemas.microsoft.com/wix/2006/localization"> | ||
<String Id="LicenseAgreementDlgTitle">Software License</String> | ||
<String Id="LicenseAgreementDlgDescription">Please read the following license carefully</String> | ||
<String Id="LicenseAgreementDlgLicenseAcceptedCheckBox">I acknowldege the license.</String> | ||
</WixLocalization> |
Oops, something went wrong.