From 135ef3cc688190da3429811730aae8f03373a554 Mon Sep 17 00:00:00 2001 From: KitsuneSolar Date: Sun, 12 Nov 2023 05:48:41 +0000 Subject: [PATCH] 2023-11-12 05:48:40 --- CHANGELOG.md | 0 CONTRIBUTING.md | 14 +++++++++ LICENSE | 2 +- PkgStore.FFmpeg.psd1 | 19 ++++++++++++ PkgStore.FFmpeg.psm1 | 70 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 PkgStore.FFmpeg.psd1 create mode 100644 PkgStore.FFmpeg.psm1 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c5b4523 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,14 @@ +# Contributing + +- Feedback, wishes and suggestions can be sent by email. +- Constructive criticism, bug descriptions and other reports are welcome. +- Email: [mail@ihub.to](mailto:mail@ihub.to). + +## Sources + +- [**GitHub**](https://github.com/pkgstore) +- [GitLab](https://gitlab.com/pkgstore) (MIRROR) +- [Codeberg](https://codeberg.org/pkgstore) (MIRROR) +- [Disroot](https://git.disroot.org/pkgstore) (MIRROR) +- [MosHub](https://hub.mos.ru/pkgstore) (MIRROR) +- [Git.Org.Ru](https://git.org.ru/pkgstore) (MIRROR) diff --git a/LICENSE b/LICENSE index 8dbae8f..9cc965c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Package Store +Copyright (c) 2023 iHub.TO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PkgStore.FFmpeg.psd1 b/PkgStore.FFmpeg.psd1 new file mode 100644 index 0000000..0aa1cd3 --- /dev/null +++ b/PkgStore.FFmpeg.psd1 @@ -0,0 +1,19 @@ +@{ + RootModule = 'PkgStore.FFmpeg.psm1' + ModuleVersion = '0.1.0' + GUID = '82549e1a-69f4-407b-baff-4f97d75b9852' + Author = 'Kitsune Solar' + CompanyName = 'iHub.TO' + Copyright = '(c) 2023 Kitsune Solar. All rights reserved.' + Description = '' + PowerShellVersion = '7.1' + RequiredModules = @('PkgStore.Kernel') + FunctionsToExport = @('Compress-Video') + PrivateData = @{ + PSData = @{ + Tags = @('pwsh', 'ffmpeg') + LicenseUri = 'https://github.com/pkgstore/pwsh-ffmpeg/blob/main/LICENSE' + ProjectUri = 'https://github.com/pkgstore/pwsh-ffmpeg' + } + } +} diff --git a/PkgStore.FFmpeg.psm1 b/PkgStore.FFmpeg.psm1 new file mode 100644 index 0000000..04c3d33 --- /dev/null +++ b/PkgStore.FFmpeg.psm1 @@ -0,0 +1,70 @@ +<#PSScriptInfo + .VERSION 0.1.0 + .GUID 82549e1a-69f4-407b-baff-4f97d75b9852 + .AUTHOR Kitsune Solar + .AUTHOREMAIL mail@kitsune.solar + .COMPANYNAME iHub.TO + .COPYRIGHT 2023 Kitsune Solar. All rights reserved. + .LICENSEURI https://github.com/pkgstore/pwsh-curl/blob/main/LICENSE + .PROJECTURI +#> + +$App = @('ffmpeg.exe') +$AppExe = @{LiteralPath = "${PSScriptRoot}"; Filter = "$($App[0])"; Recurse = $true; File = $true} +$AppExe = ((Get-ChildItem @AppExe) | Select-Object -First 1) +$NL = "$([Environment]::NewLine)" + +function Compress-Video() { + <# + .SYNOPSIS + + .DESCRIPTION + #> + + Param( + [Parameter(Mandatory)][Alias('F')][string[]]$P_Files, + [Alias('CV')][string]$P_vCodec = 'libx265', + [Alias('CA')][string]$P_aCodec = 'copy', + [Alias('R')][int]$P_Framerate, + [Alias('C')][int]$P_CRF, + [Alias('PS')][string]$P_Preset, + [Alias('EXT')][string]$P_Extension = 'mp4' + ) + + Test-App + + (Get-ChildItem $P_Files -File)| ForEach-Object { + # Composing a app command. + $Param = @('-hide_banner') + $Param += @('-i', "${_}") + $Param += @('-c:v', "${P_vCodec}") + if ($P_CRF) { $Param += @('-crf', "${P_CRF}") } + if ($P_Preset) { $Param += @('-preset', "${P_Preset}") } + if ($P_Framerate) { $Param += @('-r', "${P_Framerate}") } + $Param += @('-c:a', "${P_aCodec}") + $Param += @("$($(Join-Path $_.DirectoryName $_.BaseName).$P_Extension)") + + # Running a app. + & "${AppExe}" $Param + } +} + +function Test-App { + <# + .SYNOPSIS + + .DESCRIPTION + #> + + # Getting 'curl.exe' directory. + $Dir = "$($AppExe.DirectoryName)" + + # Checking the location of files. + $App | ForEach-Object { + if (-not (Test-Data -T 'F' -P "${Dir}\${_}")) { + Write-Msg -T 'W' -A 'Stop' -M ("'${_}' not found!${NL}${NL}" + + "1. Download '${_}' from 'https://www.gyan.dev/ffmpeg/builds/'.${NL}" + + "2. Extract all the contents of the archive into a directory '${PSScriptRoot}'.") + } + } +}