继续操作前请注册或者登录。
胡斌

close app 5s later after closing pipe ,to let the ffmpeg flush mp4 moov

正在显示 1 个修改的文件 包含 11 行增加3 行删除
@@ -23,9 +23,15 @@ ipc.on('close-main-window', function () { @@ -23,9 +23,15 @@ ipc.on('close-main-window', function () {
23 var lastRenderTime = 0; 23 var lastRenderTime = 0;
24 24
25 ipc.on('to-main-timer', function () { 25 ipc.on('to-main-timer', function () {
26 - if(Date.now() - lastRenderTime >= 10000){ 26 + if (Date.now() - lastRenderTime >= 10000) {
  27 + if (streamIn) {
  28 + streamIn.end();
  29 + streamIn = null;
  30 + }
  31 + if (Date.now() - lastRenderTime >= 15000) {
27 quit(); 32 quit();
28 - } 33 + }
  34 + }
29 }); 35 });
30 36
31 var subarg = require('subarg'); 37 var subarg = require('subarg');
@@ -113,7 +119,9 @@ win.webContents.executeJavaScript('const ipcToMain = require("electron").ipcRend @@ -113,7 +119,9 @@ win.webContents.executeJavaScript('const ipcToMain = require("electron").ipcRend
113 streamIn = null; 119 streamIn = null;
114 } 120 }
115 console.log("done") 121 console.log("done")
116 - win.webContents.executeJavaScript('require("electron").ipcRenderer.send("close-main-window")'); 122 + if(elapsed > duration + 5000){//delay 5s after closing pipe ,then close
  123 + win.webContents.executeJavaScript('require("electron").ipcRenderer.send("close-main-window")');
  124 + }
117 } 125 }
118 else { 126 else {
119 streamIn.write(image.getBitmap()); 127 streamIn.write(image.getBitmap());