Browse Source

fix: webcam no longer throws if no frames are recorded

Paul Frazee 5 years ago
parent
commit
aa864e01d0
1 changed files with 13 additions and 7 deletions
  1. 13
    7
      ui/lib/com/webcam-giffer-form.js

+ 13
- 7
ui/lib/com/webcam-giffer-form.js View File

@@ -241,17 +241,23 @@ module.exports = function (rootMsg, branchMsg, opts) {
241 241
     // stop capture
242 242
     clearInterval(recordInterval)
243 243
 
244
-    // show output stream
245
-    invideo.classList.add('hide')
246
-    outvideo.classList.remove('hide')
247
-
248 244
     // remove 'recording' border
249 245
     invideo.classList.remove('recording')
250 246
 
251 247
     // produce output
252
-    blob = encoder.compile()
253
-    console.log('Webm video encoded:', blob.size, 'bytes')
254
-    outvideo.src = URL.createObjectURL(blob, 'video/webm')
248
+    if (encoder.frames && encoder.frames.length) {
249
+      blob = encoder.compile()
250
+      console.log('Webm video encoded:', blob.size, 'bytes')
251
+      outvideo.src = URL.createObjectURL(blob, 'video/webm')
252
+
253
+      // show output stream
254
+      invideo.classList.add('hide')
255
+      outvideo.classList.remove('hide')
256
+    } else {
257
+      // show input stream
258
+      invideo.classList.remove('hide')
259
+      outvideo.classList.add('hide')
260
+    }
255 261
     enable()
256 262
   }
257 263
 

Loading…
Cancel
Save