4.6.0: video muting and soundcloud client_id

This commit is contained in:
wukko
2022-12-17 17:09:49 +06:00
parent f13a82e152
commit 7f1ba6b36b
26 changed files with 179 additions and 74 deletions

View File

@@ -22,8 +22,9 @@ export function createStream(obj) {
exp: exp,
isAudioOnly: !!obj.isAudioOnly,
audioFormat: obj.audioFormat,
time: obj.time,
copy: obj.copy,
time: obj.time ? obj.time : false,
copy: obj.copy ? true : false,
mute: obj.mute ? true : false,
metadata: obj.fileMetadata ? obj.fileMetadata : false
});
return `${process.env.selfURL}api/stream?t=${streamUUID}&e=${exp}&h=${ghmac}`;

View File

@@ -1,6 +1,6 @@
import { apiJSON } from "../sub/utils.js";
import { verifyStream } from "./manage.js";
import { streamAudioOnly, streamDefault, streamLiveRender } from "./types.js";
import { streamAudioOnly, streamDefault, streamLiveRender, streamVideoOnly } from "./types.js";
export default function(res, ip, id, hmac, exp) {
try {
@@ -13,6 +13,9 @@ export default function(res, ip, id, hmac, exp) {
case "render":
streamLiveRender(streamInfo, res);
break;
case "mute":
streamVideoOnly(streamInfo, res);
break;
default:
streamDefault(streamInfo, res);
break;

View File

@@ -6,7 +6,9 @@ import { metadataManager, msToTime } from "../sub/utils.js";
export function streamDefault(streamInfo, res) {
try {
res.setHeader('Content-disposition', `attachment; filename="${streamInfo.isAudioOnly ? `${streamInfo.filename}.${streamInfo.audioFormat}` : streamInfo.filename}"`);
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1]
let regFilename = !streamInfo.mute ? streamInfo.filename : `${streamInfo.filename.split('.')[0]}_mute.${format}`
res.setHeader('Content-disposition', `attachment; filename="${streamInfo.isAudioOnly ? `${streamInfo.filename}.${streamInfo.audioFormat}` : regFilename}"`);
const stream = got.get(streamInfo.urls, {
headers: {
"user-agent": genericUserAgent
@@ -96,3 +98,31 @@ export function streamAudioOnly(streamInfo, res) {
res.end();
}
}
export function streamVideoOnly(streamInfo, res) {
try {
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
'-loglevel', '-8',
'-i', streamInfo.urls,
'-c', 'copy', '-an'
]
if (format == "mp4") args.push('-movflags', 'faststart+frag_keyframe+empty_moov')
args.push('-f', format, 'pipe:3');
const ffmpegProcess = spawn(ffmpeg, args, {
windowsHide: true,
stdio: [
'inherit', 'inherit', 'inherit',
'pipe'
],
});
res.setHeader('Connection', 'keep-alive');
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename.split('.')[0]}_mute.${format}"`);
ffmpegProcess.stdio[3].pipe(res);
ffmpegProcess.on('error', (err) => {
ffmpegProcess.kill();
res.end();
});
} catch (e) {
res.end();
}
}