mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
Fix tab indentation
This commit is contained in:
+28
-28
@@ -53,38 +53,38 @@ registerMediabunnyServer();
|
|||||||
|
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
// Read the request body as a stream
|
// Read the request body as a stream
|
||||||
const stream = Readable.toWeb(req) as ReadableStream<Uint8Array>;
|
const stream = Readable.toWeb(req) as ReadableStream<Uint8Array>;
|
||||||
const input = new Input({
|
const input = new Input({
|
||||||
source: new ReadableStreamSource(stream),
|
source: new ReadableStreamSource(stream),
|
||||||
formats: ALL_FORMATS,
|
formats: ALL_FORMATS,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stream the output directly to the disk, could also stream to S3 etc.
|
// Stream the output directly to the disk, could also stream to S3 etc.
|
||||||
const output = new Output({
|
const output = new Output({
|
||||||
format: new Mp4OutputFormat(),
|
format: new Mp4OutputFormat(),
|
||||||
target: new FilePathTarget(`./converted-${crypto.randomUUID()}.mp4`),
|
target: new FilePathTarget(`./converted-${crypto.randomUUID()}.mp4`),
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const conversion = await Conversion.init({
|
const conversion = await Conversion.init({
|
||||||
input,
|
input,
|
||||||
output,
|
output,
|
||||||
video: async track => ({
|
video: async track => ({
|
||||||
codec: 'avc',
|
codec: 'avc',
|
||||||
height: Math.min(720, await track.getDisplayHeight()),
|
height: Math.min(720, await track.getDisplayHeight()),
|
||||||
bitrate: QUALITY_MEDIUM,
|
bitrate: QUALITY_MEDIUM,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
await conversion.execute();
|
await conversion.execute();
|
||||||
|
|
||||||
res.statusCode = 204;
|
res.statusCode = 204;
|
||||||
res.end();
|
res.end();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
res.end();
|
res.end();
|
||||||
|
|
||||||
console.error("Error processing media:", error);
|
console.error("Error processing media:", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(3000);
|
server.listen(3000);
|
||||||
|
|||||||
Reference in New Issue
Block a user