From a08eff4abbcdb1ae78b4b27f0171c4046486219c Mon Sep 17 00:00:00 2001
From: Michael <michael.foiani@gmail.com>
Date: Fri, 3 Jun 2022 12:25:31 -0400
Subject: ffmpeg testing

---
 .../views/nodes/RecordingBox/RecordingView.tsx     | 50 ++++++++++++++++------
 1 file changed, 38 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/RecordingBox/RecordingView.tsx')

diff --git a/src/client/views/nodes/RecordingBox/RecordingView.tsx b/src/client/views/nodes/RecordingBox/RecordingView.tsx
index 994111bd4..3fd062483 100644
--- a/src/client/views/nodes/RecordingBox/RecordingView.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingView.tsx
@@ -7,9 +7,9 @@ import { FaCheckCircle } from 'react-icons/fa';
 import { IconContext } from "react-icons";
 import { Networking } from '../../../Network';
 import { Upload } from '../../../../server/SharedMediaTypes';
-const ffmpeg = require("fluent-ffmpeg");
 
 import { RecordingApi } from '../../../util/RecordingApi';
+import { DashUploadUtils } from '../../../../server/DashUploadUtils';
 
 interface MediaSegment {
     videoChunks: any[],
@@ -61,24 +61,50 @@ export function RecordingView(props: IRecordingViewProps) {
           if (finished) {
               (async () => {
                 const inputPaths: string[] = [];
+                const videoFiles: File[] = []
                   videos.forEach(async (vid, i) => {
                     const videoFile = new File(vid.videoChunks, `segvideo${i}.mkv`, { type: vid.videoChunks[0].type, lastModified: Date.now() });
+                    videoFiles.push(videoFile);
+                    
                     const { name } = videoFile;
-                    ffmpeg(name)
                     inputPaths.push(name)
                   });
-
-                  
+                
+                
+                
+                // const inputListName = 'order.txt';
+                // fs.writeFileSync(inputListName, inputPaths.join('\n'));
+
+                // var merge = ffmpeg();
+                // merge.input(inputListName)
+                //   .inputOptions(['-f concat', '-safe 0'])
+                //   .outputOptions('-c copy')
+                //   .save('output.mp4')
+                
+                // fs.unlinkSync(inputListName);
+
+                const combined = await DashUploadUtils.combineSegments(videoFiles, inputPaths)
+                console.log('combined', combined)
+                
+                // const outputFile = new File(['output.mp4'], 'output.mp4', { type: 'video/mp4', lastModified: Date.now() });
+
+                const data = await Networking.UploadFilesToServer(combined)
+                  const result = data[0].result
+                  if (!(result instanceof Error)) { // convert this screenshotBox into normal videoBox
+                      props.setResult(result, trackScreen)
+                  } else {
+                      alert("video conversion failed");
+                  }
                   
 
-                  if (format.includes("x-matroska")) {
-                    await new Promise(res => ffmpeg(file.path)
-                        .videoCodec("copy") // this will copy the data instead of reencode it
-                        .save(file.path.replace(".mkv", ".mp4"))
-                        .on('end', res));
-                    file.path = file.path.replace(".mkv", ".mp4");
-                    format = ".mp4";
-                }
+                //   if (format.includes("x-matroska")) {
+                //     await new Promise(res => ffmpeg(file.path)
+                //         .videoCodec("copy") // this will copy the data instead of reencode it
+                //         .save(file.path.replace(".mkv", ".mp4"))
+                //         .on('end', res));
+                //     file.path = file.path.replace(".mkv", ".mp4");
+                //     format = ".mp4";
+                // }
                 //   console.log('crossOriginIsolated', crossOriginIsolated)
                 //   props.setDuration(recordingTimer * 100)
 
-- 
cgit v1.2.3-70-g09d2

