mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
tweak video processing
This commit is contained in:
parent
288846ff99
commit
582c7e389b
@ -13,36 +13,31 @@ import videoTranscode from "@services/videoTranscode"
|
|||||||
* @throws {Error} Throws an error if file parameter is not provided.
|
* @throws {Error} Throws an error if file parameter is not provided.
|
||||||
* @return {Object} The processed video file object.
|
* @return {Object} The processed video file object.
|
||||||
*/
|
*/
|
||||||
async function processVideo(
|
async function processVideo(file, options = {}) {
|
||||||
file,
|
if (!file) {
|
||||||
options = {},
|
throw new Error("file is required")
|
||||||
) {
|
}
|
||||||
if (!file) {
|
|
||||||
throw new Error("file is required")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Get values from db
|
// TODO: Get values from db
|
||||||
const {
|
const {
|
||||||
videoCodec = "libx264",
|
videoCodec = "libx264",
|
||||||
format = "mp4",
|
format = "mp4",
|
||||||
audioBitrate = 128,
|
audioBitrate = 128,
|
||||||
videoBitrate = 2024,
|
videoBitrate = 3000,
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
const result = await videoTranscode(file.filepath, {
|
const result = await videoTranscode(file.filepath, {
|
||||||
videoCodec,
|
videoCodec,
|
||||||
format,
|
format,
|
||||||
audioBitrate,
|
audioBitrate,
|
||||||
videoBitrate: [videoBitrate, true],
|
videoBitrate: [videoBitrate, true],
|
||||||
extraOptions: [
|
extraOptions: ["-threads 2"],
|
||||||
"-threads 1"
|
})
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
file.filepath = result.filepath
|
file.filepath = result.filepath
|
||||||
file.filename = result.filename
|
file.filename = result.filename
|
||||||
|
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
export default processVideo
|
export default processVideo
|
Loading…
x
Reference in New Issue
Block a user