add ffmpeg

This commit is contained in:
AJ ONeal
2020-11-18 17:34:32 -07:00
parent 9ee3af1afb
commit 0aa421a042
4 changed files with 158 additions and 0 deletions

27
ffmpeg/README.md Normal file
View File

@@ -0,0 +1,27 @@
---
title: ffmpeg
homepage: https://ffmpeg.org/
tagline: |
FFmpeg: A complete, cross-platform solution to record, convert and stream audio and video.
---
## Updating `ffmpeg`
```bash
webi ffmpeg@stable
```
Disclaimer: ffmpeg does not provide official binaries, so
<https://github.com/eugeneware/ffmpeg-static> is used.
## Cheat Sheet
> FFmpeg is useful for converting between various audio, video, and image
> formats.
Many simple conversions can be auto-detected by file extension and the options
that produce the most similar quality by default.
```bash
ffmpeg -i input.m4a output.mp3
```

View File

@@ -1 +1,51 @@
#!/usr/bin/env pwsh
##################
# Install ffmpeg #
##################
# Every package should define these variables
$pkg_cmd_name = "ffmpeg"
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\ffmpeg.exe"
$pkg_dst = "$pkg_dst_cmd"
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\ffmpeg-v$Env:WEBI_VERSION\bin\ffmpeg.exe"
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\ffmpeg-v$Env:WEBI_VERSION\bin"
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\ffmpeg-v$Env:WEBI_VERSION"
$pkg_src = "$pkg_src_cmd"
$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
# Fetch archive
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
{
# TODO: arch detection
echo "Downloading ffmpeg from $Env:WEBI_PKG_URL to $pkg_download"
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
Move-Item -Path "$pkg_download.part" -Destination "$pkg_download" -Force
}
IF (!(Test-Path -Path "$pkg_src_cmd"))
{
echo "Installing ffmpeg"
# TODO: create package-specific temp directory
# Enter tmp
pushd .local\tmp
# Remove any leftover tmp cruft
Remove-Item -Path ".\win32-*" -Recurse -ErrorAction Ignore
# Settle unpacked archive into place
echo "Install Location: $pkg_src_cmd"
New-Item "$pkg_src_bin" -ItemType Directory -Force
Move-Item -Path "$pkg_download" -Destination "$pkg_src_cmd" -Force
# Exit tmp
popd
}
echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse

41
ffmpeg/install.sh Normal file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
{
set -e
set -u
##################
# Install ffmpeg #
##################
# Every package should define these 6 variables
pkg_cmd_name="ffmpeg"
pkg_dst_cmd="$HOME/.local/bin/ffmpeg"
pkg_dst="$pkg_dst_cmd"
pkg_src_cmd="$HOME/.local/opt/ffmpeg-v$WEBI_VERSION/bin/ffmpeg"
pkg_src_dir="$HOME/.local/opt/ffmpeg-v$WEBI_VERSION"
pkg_src="$pkg_src_cmd"
# pkg_install must be defined by every package
pkg_install() {
# ~/.local/opt/ffmpeg-v4.3.1/bin
mkdir -p "$(dirname $pkg_src_cmd)"
# mv ./linux-x86 ~/.local/opt/ffmpeg-v4.3.1/bin/ffmpeg
mv ./*-* "$pkg_src_cmd"
}
# pkg_get_current_version is recommended, but (soon) not required
pkg_get_current_version() {
# 'ffmpeg -version' has output in this format:
# ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
# built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
# ...
# This trims it down to just the version number:
# 4.3.1
echo $(ffmpeg -version 2>/dev/null | head -n 1 | cut -d ' ' -f 3)
}
}

40
ffmpeg/releases.js Normal file
View File

@@ -0,0 +1,40 @@
'use strict';
var path = require('path');
var github = require('../_common/github.js');
var owner = 'eugeneware';
var repo = 'ffmpeg-static';
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases
.filter(function (rel) {
// remove README and LICENSE
return !['.README', '.LICENSE'].includes(path.extname(rel.name));
})
.map(function (rel) {
rel.version = rel.version.replace(/^b/, '');
if (/win32/.test(rel.name)) {
rel.os = 'windows';
rel.ext = 'exe';
}
if (/ia32/.test(rel.name)) {
rel.arch = '386';
} else if (/x64/.test(rel.name)) {
rel.arch = 'amd64';
}
return rel;
});
return all;
});
};
if (module === require.main) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});
}