freealise commited on
Commit
8945278
·
verified ·
1 Parent(s): ae2fe69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -925,6 +925,29 @@ if (BABYLON) {
925
  }
926
  window.snapshot = snapshot;
927
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
928
  function applyDisplacementMapFromBuffer(
929
  mesh,
930
  buffer,
@@ -1247,7 +1270,9 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
1247
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
1248
  '/><span>1.0</span>""")
1249
  snapshot = gr.HTML(value="""
1250
- <a onclick='snapshot();'>Screenshot</a><br/>
 
 
1251
  <img src='' id='img_out' onload='var ctxt = document.getElementById(\"cnv_out\").getContext(\"2d\");ctxt.drawImage(this, 0, 0);'/><br/>
1252
  <canvas id='cnv_out'></canvas>
1253
  <div id='compass_box'><div id='compass'><a id='fullscreen' onclick='
 
925
  }
926
  window.snapshot = snapshot;
927
 
928
+
929
+ window.recorder = null;
930
+
931
+ function record_video() {
932
+ try {
933
+ if (BABYLON.VideoRecorder.IsSupported(BABYLON.Engine) && (recorder == null || !recorder.isRecording) ) {
934
+ if (recorder == null) {
935
+ recorder = new BABYLON.VideoRecorder(BABYLON.Engine, { mimeType:'video/mp4', fps:25, /*audioTracks: mediaStreamDestination.stream.getAudioTracks()*/ });
936
+ }
937
+ recorder.startRecording('video.mp4', 60*60);
938
+ }
939
+ } catch(e) {alert(e);}
940
+ }
941
+ window.record_video = record_video;
942
+
943
+ function stop_recording() {
944
+ if (recorder.isRecording) {
945
+ recorder.stopRecording();
946
+ }
947
+ }
948
+ window.stop_recording = stop_recording;
949
+
950
+
951
  function applyDisplacementMapFromBuffer(
952
  mesh,
953
  buffer,
 
1270
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
1271
  '/><span>1.0</span>""")
1272
  snapshot = gr.HTML(value="""
1273
+ <a href='#' onclick='snapshot();'>Screenshot</a>
1274
+ <a href='#' onclick='record_video();'>Record</a>
1275
+ <a href='#' onclick='stop_recording();'>Stop</a><br/>
1276
  <img src='' id='img_out' onload='var ctxt = document.getElementById(\"cnv_out\").getContext(\"2d\");ctxt.drawImage(this, 0, 0);'/><br/>
1277
  <canvas id='cnv_out'></canvas>
1278
  <div id='compass_box'><div id='compass'><a id='fullscreen' onclick='