Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ No need to install other programs as ffmpeg-cli will download and extract necess
## Supported OS
+ MacOS ~ 64 bit
+ Linux ~ 32/64 bit
+ Windows ~ 32/64 bit
+ Windows ~ [~~32/~~](https://github.com/PotatoParser/ffmpeg-cli/issues/9)64 bit

## FFmpeg Path
Returns the path of FFmpeg executable
Expand Down
14 changes: 10 additions & 4 deletions lib/download.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const https = require('https');
const { https } = require('follow-redirects');
const tar = require('tar');
const AdmZip = require('adm-zip');
const lzma = require('lzma-native');
Expand Down Expand Up @@ -48,7 +48,7 @@ async function getPackage(){
if (fs.existsSync(system.typePath)) rimraf(system.typePath);
if (!fs.existsSync(`${system.rootDir}/ffmpeg`)) fs.mkdirSync(`${system.rootDir}/ffmpeg`);
var downloaded = await new Promise(resolve=>{
https.get(system.url, res => {
https.get(system.url, {headers: {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'}}, res => {
res.on('error', ()=>resolve(false));
res.pipe(fs.createWriteStream(system.zipPath)).on('finish', ()=>resolve(true));
let bar = console.bar(parseInt(res.headers['content-length'], 10));
Expand All @@ -62,8 +62,14 @@ async function getPackage(){
console.log('Unzipped files');
fs.unlinkSync(system.zipPath);

console.log('Renaming files');
fs.renameSync(temp, system.typePath);
if (system.file) {
console.log('Moving files');
fs.mkdirSync(system.typePath);
fs.renameSync(system.file, system.path);
} else {
console.log('Renaming files');
fs.renameSync(system.dir, system.typePath);
}

console.log('Applying chmod');
fs.readdirSync(system.pathDir, { withFileTypes: true }).forEach(f => {
Expand Down
21 changes: 11 additions & 10 deletions lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,38 @@ const console = require('./console');
const rootDir = path.join(__dirname, '..');
const OS = process.platform;
const BIT = process.arch;
if (!(BIT === 'x32' || BIT === 'x64')) error('CPU architecture not supported');
if (!(BIT === 'x32' || BIT === 'x64')) console.error('CPU architecture not supported');
const allOS = {
linux: {
x32: {
url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz',
dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-amd64-static',
path: rootDir + '/ffmpeg/linuxx32/ffmpeg'
},
x64: {
url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz',
dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-i686-static',
path: rootDir + '/ffmpeg/linuxx64/ffmpeg'
}
},
darwin: {
x64: {
url: 'https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-4.2.2-macos64-static.zip',
path: rootDir + '/ffmpeg/darwinx64/bin/ffmpeg'
url: 'https://evermeet.cx/ffmpeg/ffmpeg-4.3.1.zip',
file: rootDir + '/ffmpeg/ffmpeg',
path: rootDir + '/ffmpeg/darwinx64/ffmpeg'
}
},
win32: {
x32: {
url: 'https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip',
path: rootDir + '/ffmpeg/win32x32/bin/ffmpeg.exe'
},
x64: {
url: 'https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip',
url: 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2020-09-26-14-24/ffmpeg-n4.3.1-18-g6d886b6586-win64-gpl-4.3.zip',
dir: rootDir + '/ffmpeg/ffmpeg-n4.3.1-18-g6d886b6586-win64-gpl-4.3',
path: rootDir + '/ffmpeg/win32x64/bin/ffmpeg.exe'
}
}
}
if (allOS[OS] === undefined) console.error('OS not supporteds!');
if (allOS[OS][BIT] === undefined) console.error('Invalid OS and CPU architecture!');
if (!allOS[OS]) console.error('OS not supporteds!');
if (!allOS[OS][BIT]) console.error('Invalid OS and CPU architecture!');

module.exports = Object.assign({}, allOS[OS][BIT]);
module.exports.typePath = path.normalize(rootDir + '/ffmpeg/' + OS + BIT);
module.exports.zipPath = path.normalize(rootDir + '/ffmpeg/' + module.exports.url.substring(module.exports.url.lastIndexOf('/')+1));
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffmpeg-cli",
"version": "2.5.2",
"version": "2.6.0",
"description": "ffmpeg with support for multiple OSs",
"main": "./lib/index.js",
"scripts": {
Expand All @@ -27,6 +27,7 @@
"homepage": "https://github.com/PotatoParser/ffmpeg-cli#readme",
"dependencies": {
"adm-zip": "^0.4.14",
"follow-redirects": "^1.13.0",
"lzma-native": "^5.0.1",
"progress": "^2.0.3",
"tar": "^6.0.2"
Expand Down