aboutsummaryrefslogtreecommitdiff
path: root/src/server/DashUploadUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/DashUploadUtils.ts')
-rw-r--r--src/server/DashUploadUtils.ts59
1 files changed, 14 insertions, 45 deletions
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 148b0df65..be30c115d 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -63,21 +63,20 @@ export namespace DashUploadUtils {
const { imageFormats, videoFormats, applicationFormats, audioFormats } = AcceptableMedia; //TODO:glr
- export async function concatenateVideos(filePaths: string[]): Promise<Upload.FileResponse> {
+ export async function concatVideos(filePaths: string[]): Promise<Upload.AccessPathInfo> {
// make a list of paths to create the ordered text file for ffmpeg
- //const filePaths = videoFiles.map(file => file.path);
- // write the text file to the file system
const inputListName = 'concat.txt';
const textFilePath = path.join(filesDirectory, inputListName);
// make a list of paths to create the ordered text file for ffmpeg
- const filePathsText = filePaths.map(filePath => `file '${filePath}'`).join('\n');
+ const filePathsText = filePaths.map(filePath => `file '${filePath}'`).join('\n');
+ // write the text file to the file system
writeFile(textFilePath, filePathsText, (err) => console.log(err));
- console.log(filePathsText)
+ console.log('fileTextPaths', filePathsText)
// make output file name based on timestamp
- const outputFileName = `output-${Utils.GenerateGuid()}.mkv`;
- // create the output file path in the parsed_file directory
- const outputFilePath = path.join(filesDirectory, outputFileName);
+ const outputFileName = `output-${Utils.GenerateGuid()}.mp4`;
+ // create the output file path in the videos directory
+ const outputFilePath = path.join(pathToDirectory(Directory.videos), outputFileName);
// concatenate the videos
await new Promise((resolve, reject) => {
@@ -92,45 +91,15 @@ export namespace DashUploadUtils {
.on("end", resolve);
})
- // delete concat.txt from the file system
- unlinkSync(textFilePath);
-
- // read the output file from the file system
- // const outputFile = fs.readFileSync(outputFilePath);
-
- // make a new blob object with the output file buffer
- // const outputFileBlob = new Blob([outputFile.buffer], { type: 'x-matroska/mkv' });
-
- // TODO: make with toJSON()
+ // delete concat.txt from the file system
+ unlinkSync(textFilePath);
+ // delete the old segment videos from the server
+ filePaths.forEach(filePath => unlinkSync(filePath));
- // make a data object
- const outputFileObject: formidable.File = {
- size: 0,
- name: outputFileName,
- path: outputFilePath,
- // size: outputFileBlob.size,
- type: 'video/x-matroska;codecs=avc1,opus',
- lastModifiedDate: new Date(),
-
- toJSON: () => ({ ...outputFileObject, filename: outputFilePath.replace(/.*\//, ""), mtime: null, length: 0, mime: "", toJson: () => undefined as any })
+ // return the path(s) to the output file
+ return {
+ accessPaths: getAccessPaths(Directory.videos, outputFileName)
}
-
- // const file = { ...outputFileObject, toJSON: () => ({ ...outputFileObject, filename: outputFilePath.replace(/.*\//, ""), mtime: null, length: 0, mime: "", toJson: () => undefined as any }) };
-
- // this will convert it to mp4 and save it to the server
- //return await MoveParsedFile(outputFileObject, Directory.videos);
-
- return await upload(outputFileObject);
-
- // // return only the output (first) file to the videos directory
- // return {
- // source: file, result: {
- // accessPaths: {
- // agnostic: getAccessPaths(Directory.videos, outputFileName)
- // },
- // rawText: undefined
- // }
- // }
}
export function uploadYoutube(videoId: string): Promise<Upload.FileResponse> {