more tags, ffprobe
This commit is contained in:
parent
107cb29f73
commit
ffef2ecddf
5 changed files with 221 additions and 6 deletions
1
app.js
1
app.js
|
@ -13,6 +13,7 @@ let indexRouter = require('./routes/index');
|
||||||
let authRouter = require('./routes/auth');
|
let authRouter = require('./routes/auth');
|
||||||
|
|
||||||
let app = express();
|
let app = express();
|
||||||
|
app.enable('trust proxy');
|
||||||
|
|
||||||
// view engine setup
|
// view engine setup
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set('views', path.join(__dirname, 'views'));
|
||||||
|
|
181
package-lock.json
generated
181
package-lock.json
generated
|
@ -10,6 +10,7 @@
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||||
|
"@ffprobe-installer/ffprobe": "^1.4.1",
|
||||||
"connect-sqlite3": "^0.9.13",
|
"connect-sqlite3": "^0.9.13",
|
||||||
"cookie-parser": "~1.4.4",
|
"cookie-parser": "~1.4.4",
|
||||||
"dotenv": "^8.6.0",
|
"dotenv": "^8.6.0",
|
||||||
|
@ -142,6 +143,123 @@
|
||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@ffprobe-installer/darwin-arm64": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/darwin-arm64/-/darwin-arm64-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-vwNCNjokH8hfkbl6m95zICHwkSzhEvDC3GVBcUp5HX8+4wsX10SP3B+bGur7XUzTIZ4cQpgJmEIAx6TUwRepMg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/darwin-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/darwin-x64/-/darwin-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-Zl0UkZ+wW/eyMKBPLTUCcNQch2VDnZz/cBn1DXv3YtCBVbYd9aYzGj4MImdxgWcoE0+GpbfbO6mKGwMq5HCm6A==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/ffprobe": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/ffprobe/-/ffprobe-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-3WJvxU0f4d7IOZdzoVCAj9fYtiQNC6E0521FJFe9iP5Ej8auTXU7TsrUzIAG1CydeQI+BnM3vGog92SCcF9KtA==",
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@ffprobe-installer/darwin-arm64": "5.0.1",
|
||||||
|
"@ffprobe-installer/darwin-x64": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-arm": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-arm64": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-ia32": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-x64": "5.0.0",
|
||||||
|
"@ffprobe-installer/win32-ia32": "5.0.0",
|
||||||
|
"@ffprobe-installer/win32-x64": "5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/linux-arm": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-arm/-/linux-arm-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-mM1PPxP2UX5SUvhy0urcj5U8UolwbYgmnXA/eBWbW78k6N2Wk1COvcHYzOPs6c5yXXL6oshS2rZHU1kowigw7g==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/linux-arm64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-arm64/-/linux-arm64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-IwFbzhe1UydR849YXLPP0RMpHgHXSuPO1kznaCHcU5FscFBV5gOZLkdD8e/xrcC8g/nhKqy0xMjn5kv6KkFQlQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/linux-ia32": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-ia32/-/linux-ia32-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-c3bWlWEDMST59SAZycVh0oyc2eNS/CxxeRjoNryGRgqcZX3EJWJJQL1rAXbpQOMLMi8to1RqnmMuwPJgLLjjUA==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/linux-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-x64/-/linux-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-zgLnWJFvMGCaw1txGtz84sMEQt6mQUzdw86ih9S/kZOWnp06Gj/ams/EXxEkAxgAACCVM6/O0mkDe/6biY5tgA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/win32-ia32": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/win32-ia32/-/win32-ia32-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-NnDdAZD6ShFXzJeCkAFl2ZjAv7GcJWYudLA+0T/vjZwvskBop+sq1PGfdmVltfFDcdQiomoThRhn9Xiy9ZC71g==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@ffprobe-installer/win32-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/win32-x64/-/win32-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-P4ZMRFxVMnfMsOyTfBM/+nkTodLeOUfXNPo+X1bKEWBiZxRErqX/IHS5sLA0yAH8XmtKZcL7Cu6M26ztGcQYxw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@gar/promisify": {
|
"node_modules/@gar/promisify": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
|
||||||
|
@ -2256,6 +2374,69 @@
|
||||||
"integrity": "sha512-Drt5u2vzDnIONf4ZEkKtFlbvwj6rI3kxw1Ck9fpudmtgaZIHD4ucsWB2lCZBXRxJgXR+2IMSti+4rtM4C4rXgg==",
|
"integrity": "sha512-Drt5u2vzDnIONf4ZEkKtFlbvwj6rI3kxw1Ck9fpudmtgaZIHD4ucsWB2lCZBXRxJgXR+2IMSti+4rtM4C4rXgg==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"@ffprobe-installer/darwin-arm64": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/darwin-arm64/-/darwin-arm64-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-vwNCNjokH8hfkbl6m95zICHwkSzhEvDC3GVBcUp5HX8+4wsX10SP3B+bGur7XUzTIZ4cQpgJmEIAx6TUwRepMg==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/darwin-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/darwin-x64/-/darwin-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-Zl0UkZ+wW/eyMKBPLTUCcNQch2VDnZz/cBn1DXv3YtCBVbYd9aYzGj4MImdxgWcoE0+GpbfbO6mKGwMq5HCm6A==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/ffprobe": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/ffprobe/-/ffprobe-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-3WJvxU0f4d7IOZdzoVCAj9fYtiQNC6E0521FJFe9iP5Ej8auTXU7TsrUzIAG1CydeQI+BnM3vGog92SCcF9KtA==",
|
||||||
|
"requires": {
|
||||||
|
"@ffprobe-installer/darwin-arm64": "5.0.1",
|
||||||
|
"@ffprobe-installer/darwin-x64": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-arm": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-arm64": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-ia32": "5.0.0",
|
||||||
|
"@ffprobe-installer/linux-x64": "5.0.0",
|
||||||
|
"@ffprobe-installer/win32-ia32": "5.0.0",
|
||||||
|
"@ffprobe-installer/win32-x64": "5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/linux-arm": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-arm/-/linux-arm-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-mM1PPxP2UX5SUvhy0urcj5U8UolwbYgmnXA/eBWbW78k6N2Wk1COvcHYzOPs6c5yXXL6oshS2rZHU1kowigw7g==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/linux-arm64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-arm64/-/linux-arm64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-IwFbzhe1UydR849YXLPP0RMpHgHXSuPO1kznaCHcU5FscFBV5gOZLkdD8e/xrcC8g/nhKqy0xMjn5kv6KkFQlQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/linux-ia32": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-ia32/-/linux-ia32-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-c3bWlWEDMST59SAZycVh0oyc2eNS/CxxeRjoNryGRgqcZX3EJWJJQL1rAXbpQOMLMi8to1RqnmMuwPJgLLjjUA==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/linux-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/linux-x64/-/linux-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-zgLnWJFvMGCaw1txGtz84sMEQt6mQUzdw86ih9S/kZOWnp06Gj/ams/EXxEkAxgAACCVM6/O0mkDe/6biY5tgA==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/win32-ia32": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/win32-ia32/-/win32-ia32-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-NnDdAZD6ShFXzJeCkAFl2ZjAv7GcJWYudLA+0T/vjZwvskBop+sq1PGfdmVltfFDcdQiomoThRhn9Xiy9ZC71g==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@ffprobe-installer/win32-x64": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ffprobe-installer/win32-x64/-/win32-x64-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-P4ZMRFxVMnfMsOyTfBM/+nkTodLeOUfXNPo+X1bKEWBiZxRErqX/IHS5sLA0yAH8XmtKZcL7Cu6M26ztGcQYxw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"@gar/promisify": {
|
"@gar/promisify": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||||
|
"@ffprobe-installer/ffprobe": "^1.4.1",
|
||||||
"connect-sqlite3": "^0.9.13",
|
"connect-sqlite3": "^0.9.13",
|
||||||
"cookie-parser": "~1.4.4",
|
"cookie-parser": "~1.4.4",
|
||||||
"dotenv": "^8.6.0",
|
"dotenv": "^8.6.0",
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
let express = require('express');
|
let express = require('express');
|
||||||
let multer = require('multer');
|
let multer = require('multer');
|
||||||
let ffmpegpath = require('@ffmpeg-installer/ffmpeg').path;
|
let ffmpegpath = require('@ffmpeg-installer/ffmpeg').path;
|
||||||
|
let ffprobepath = require('@ffprobe-installer/ffprobe').path;
|
||||||
let ffmpeg = require('fluent-ffmpeg');
|
let ffmpeg = require('fluent-ffmpeg');
|
||||||
ffmpeg.setFfmpegPath(ffmpegpath);
|
ffmpeg.setFfmpegPath(ffmpegpath);
|
||||||
|
ffmpeg.setFfprobePath(ffprobepath);
|
||||||
|
|
||||||
let db = require('../db');
|
let db = require('../db');
|
||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
@ -126,8 +128,7 @@ function convert(req, res, next) {
|
||||||
.outputOptions([
|
.outputOptions([
|
||||||
'-pix_fmt yuv420p',
|
'-pix_fmt yuv420p',
|
||||||
'-c:v libx264',
|
'-c:v libx264',
|
||||||
'-movflags +faststart',
|
'-movflags +faststart'
|
||||||
"filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2'"
|
|
||||||
])
|
])
|
||||||
.noAudio()
|
.noAudio()
|
||||||
.output(nameAndExtension[0] + '.mp4')
|
.output(nameAndExtension[0] + '.mp4')
|
||||||
|
@ -154,7 +155,32 @@ router.get('/', function (req, res, next) {
|
||||||
|
|
||||||
router.get('/gifv/:file', function (req, res, next) {
|
router.get('/gifv/:file', function (req, res, next) {
|
||||||
let url = req.protocol + '://' + req.get('host') + '/uploads/' + req.params.file;
|
let url = req.protocol + '://' + req.get('host') + '/uploads/' + req.params.file;
|
||||||
return res.render('gifv', { url: url, host: req.protocol + '://' + req.get('host') });
|
let width; let height;
|
||||||
|
|
||||||
|
nameAndExtension = extension('uploads/' + req.params.file);
|
||||||
|
if (nameAndExtension[1] == '.mp4') {
|
||||||
|
ffmpeg()
|
||||||
|
.input('uploads/' + req.params.file)
|
||||||
|
.inputFormat('mp4')
|
||||||
|
.ffprobe(function(err, data) {
|
||||||
|
if (err) return next(err);
|
||||||
|
width = data.streams[0].width;
|
||||||
|
height = data.streams[0].height;
|
||||||
|
console.log(width + 'x' + height);
|
||||||
|
return res.render('gifv', { url: url, host: req.protocol + '://' + req.get('host'), width: width, height: height });
|
||||||
|
});
|
||||||
|
} else if (nameAndExtension[1] == '.gif') {
|
||||||
|
ffmpeg()
|
||||||
|
.input('uploads/' + req.params.file)
|
||||||
|
.inputFormat('gif')
|
||||||
|
.ffprobe(function(err, data) {
|
||||||
|
if (err) return next(err);
|
||||||
|
width = data.streams[0].width;
|
||||||
|
height = data.streams[0].height;
|
||||||
|
console.log(width + 'x' + height);
|
||||||
|
return res.render('gifv', { url: url, host: req.protocol + '://' + req.get('host'), width: width, height: height });
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/', [upload.array('fileupload'), convert], function(req, res, next) {
|
router.post('/', [upload.array('fileupload'), convert], function(req, res, next) {
|
||||||
|
|
|
@ -10,17 +10,23 @@ function extension(str){
|
||||||
<head>
|
<head>
|
||||||
<meta property="og:type" content="video.other"></meta>
|
<meta property="og:type" content="video.other"></meta>
|
||||||
<meta property="og:image" content="<%= host %>/uploads/<%= extension(url)[0] %>.gif"></meta>
|
<meta property="og:image" content="<%= host %>/uploads/<%= extension(url)[0] %>.gif"></meta>
|
||||||
|
<meta property="og:image:width" content="<%= width %>"></meta>
|
||||||
|
<meta property="og:image:height" content="<%= height %>"></meta>
|
||||||
|
<meta property="og:image:type" content="image/gif"></meta>
|
||||||
<meta property="og:image:secure_url" content="<%= host %>/uploads/<%= extension(url)[0] %>.gif"></meta>
|
<meta property="og:image:secure_url" content="<%= host %>/uploads/<%= extension(url)[0] %>.gif"></meta>
|
||||||
|
<meta property="og:url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
||||||
<meta property="twitter:card" content="player"></meta>
|
<meta property="twitter:card" content="player"></meta>
|
||||||
<meta property="twitter:player" content="<%= url %>"></meta>
|
<meta property="twitter:player" content="<%= url %>"></meta>
|
||||||
|
<meta property="twitter:player:width" content="<%= width %>"></meta>
|
||||||
|
<meta property="twitter:player:height" content="<%= height %>"></meta>
|
||||||
<meta property="twitter:player:stream" content="<%= url %>"></meta>
|
<meta property="twitter:player:stream" content="<%= url %>"></meta>
|
||||||
<meta property="twitter:player:stream:content_type" content="text/mp4"></meta>
|
<meta property="twitter:player:stream:content_type" content="text/mp4"></meta>
|
||||||
<meta property="og:video" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
<meta property="og:video" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
||||||
|
<meta property="og:video:width" content="<%= width %>"></meta>
|
||||||
|
<meta property="og:video:height" content="<%= height %>"></meta>
|
||||||
|
<meta property="og:video:url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
||||||
<meta property="og:video:secure_url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
<meta property="og:video:secure_url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
||||||
<meta property="og:video:type" content="text/mp4"></meta>
|
<meta property="og:video:type" content="text/mp4"></meta>
|
||||||
<!--<meta property="og:video:width" content="<%# width %>">
|
|
||||||
<meta property="og:video:height" content="<%# height %>">
|
|
||||||
<meta name="twitter:image" content="<%# thumbnail %>">-->
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<video autoplay loop muted playsinline class="image" width="100%"><source src="/uploads/<%= extension(url)[0] %>.mp4"></video>
|
<video autoplay loop muted playsinline class="image" width="100%"><source src="/uploads/<%= extension(url)[0] %>.mp4"></video>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue