Skip to content

Commit 4d1acbc

Browse files
committed
I'm crushing your head!
1 parent 886fe6b commit 4d1acbc

3 files changed

Lines changed: 87 additions & 70 deletions

File tree

apps/media/VideoCutter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*9/3/25: Instead of generalizing this app to allow for multiple files, let's create a
22
shell command that takes an arbitrary number of arguments that describe all of the
3-
clips from all of the various VideoCutter windows to assemble into a composite video.
3+
clips held by all the various VideoCutter app objects, to assemble them into a composite video.
44
One of the arguments might be a file that has a syntax to define all the clips.
55
We can also have a command that simply plays the clips in the specified order (including
6-
whatever relevant transitions there are between the clips).
7-
So we can remove the assembling logic from here and put it into the relevant command library
6+
any relevant transitions between the clips), in order to preview the composite
7+
video. So we can remove the assembling logic from here and put it into the relevant command library
88
(or into a separate file somewhere under mods/).
99
*/
1010
/*9/2/25: I want to enable the use of clips from arbitrary numbers of videos, and sequencing

coms/extra.js

Lines changed: 83 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ const globals = LOTW.globals;
3333
const{isStr, log, jlog, cwarn, cerr}=util;
3434
const{NS, fs}=globals;
3535
const fsapi = fs.api;
36-
const {normPath}=capi;
36+
const {normPath}=util;
3737
const {pathToNode}=fsapi;
38+
const {ShellMod} = globals;
39+
const {Com} = ShellMod.comClasses;
40+
//log(Com);
3841
//const{log, jlog, cwarn, cerr}=util;
3942
//»
4043

@@ -69,7 +72,81 @@ const validate_out_path = async(outpath)=>{//«
6972
return true;
7073
};//»
7174
//»
75+
const com_record = class extends Com{//«
76+
//«Priv
77+
#promCb;
78+
#mediaRecorder;
79+
#recordedChunks;
80+
#outPath;
81+
#interval;
82+
//»
83+
cancel(){//«
84+
if (!this.#mediaRecorder) return;
85+
clearInterval(this.#interval);
86+
this.#mediaRecorder.stop();
87+
setTimeout(async()=>{
88+
let blob = new Blob(this.#recordedChunks, {
89+
type: "video/webm"
90+
});
91+
let mod = await util.getMod("util.webmparser");
92+
let bytes = await util.toBytes(blob);
93+
let rv = await mod.coms.remux(this.term, bytes);
94+
await fsapi.writeFile(this.#outPath, rv);
95+
//'V_MPEG4/ISO/AVC' == CODECID
96+
// let rv = mod.coms.parse(term, bytes);
97+
//log(rv);
98+
// fsapi.writeFile(out_path, blob);
99+
// util.download(blob, outname);
100+
// Y();
101+
this.#promCb();
102+
},500);
103+
}//»
104+
async doRec() {//«
105+
return new Promise(async(Y,N)=>{
106+
this.#promCb = Y;
107+
108+
//let stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: true, preferCurrentTab: true, selfBrowserSurface: "include", systemAudio: "include" });
109+
//let stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: false});
110+
let stream = await navigator.mediaDevices.getDisplayMedia();
111+
112+
let chunks = [];
113+
this.#recordedChunks = chunks;
114+
//let options = { mimeType: "video/webm; codecs=vp9" };
115+
let options = { mimeType: "video/webm; codecs=vp8" };
116+
//mediaRecorder = new MediaRecorder(stream, options);
117+
let mediaRecorder = new MediaRecorder(stream, options);
118+
this.#mediaRecorder = mediaRecorder;
119+
mediaRecorder.ondataavailable = (e)=>{
120+
if (e.data.size > 0) {
121+
chunks.push(e.data);
122+
log("Chunk",chunks.length);
123+
}
124+
};
125+
this.#interval=setInterval(()=>{
126+
mediaRecorder.requestData();
127+
},10000);
128+
mediaRecorder.start();
129+
130+
});
72131

132+
}//»
133+
async run(){//«
134+
const {args} = this;
135+
//const terr=(arg)=>{term_error(term, arg);Y();};
136+
let outname = args.shift();
137+
if (!outname) return this.no("No outname given");
138+
let out_path = normPath(outname, this.term.cwd);
139+
log(`OUT: ${out_path}`);
140+
let okay_rv = await validate_out_path(out_path);
141+
if (isStr(okay_rv)) return this.no(okay_rv);
142+
this.#outPath = out_path;
143+
this.doRec();
144+
// The command only stops with ^C, so there is no need to await and call this.ok()
145+
// await this.doRec();//
146+
// this.ok();
147+
}//»
148+
}//»
149+
/*
73150
const com_walt = async (args, opts) => {//«
74151
let {term}=opts;
75152
let walt = (await util.getMod("util.walt")).Walt;
@@ -170,66 +247,6 @@ return terr(e.message);
170247
//log(await node.buffer);
171248
return TERM_OK;
172249
};//»
173-
174-
const com_record = (term,args)=>{//«
175-
return new Promise(async(Y,N)=>{
176-
177-
const terr=(arg)=>{term_error(term, arg);Y();};
178-
let outname = args.shift();
179-
if (!outname) return terr("No outname given");
180-
let out_path = normPath(outname, term.cur_dir);
181-
let okay_rv = await validate_out_path(out_path);
182-
if (isStr(okay_rv)) return terr(okay_rv);
183-
outname = out_path.split("/").pop();
184-
185-
let interval;
186-
let mediaRecorder;
187-
188-
term.kill_register(()=>{//«
189-
if (!mediaRecorder) return;
190-
clearInterval(interval);
191-
mediaRecorder.stop();
192-
setTimeout(async()=>{
193-
let blob = new Blob(recordedChunks, {
194-
type: "video/webm"
195-
});
196-
let mod = await util.getMod("webmparser");
197-
let bytes = await util.toBytes(blob);
198-
let rv = await mod.coms.remux(term, bytes);
199-
await fsapi.writeFile(out_path, rv);
200-
201-
//'V_MPEG4/ISO/AVC' == CODECID
202-
// let rv = mod.coms.parse(term, bytes);
203-
//log(rv);
204-
// fsapi.writeFile(out_path, blob);
205-
// util.download(blob, outname);
206-
Y();
207-
},500);
208-
});//»
209-
210-
//let stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: true, preferCurrentTab: true, selfBrowserSurface: "include", systemAudio: "include" });
211-
//let stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: false});
212-
let stream = await navigator.mediaDevices.getDisplayMedia();
213-
214-
let recordedChunks = [];
215-
216-
//let options = { mimeType: "video/webm; codecs=vp9" };
217-
let options = { mimeType: "video/webm; codecs=vp8" };
218-
//mediaRecorder = new MediaRecorder(stream, options);
219-
mediaRecorder = new MediaRecorder(stream, options);
220-
mediaRecorder.ondataavailable = (e)=>{
221-
if (e.data.size > 0) {
222-
recordedChunks.push(e.data);
223-
log("Chunk",recordedChunks.length);
224-
}
225-
};
226-
interval=setInterval(()=>{
227-
mediaRecorder.requestData();
228-
},10000);
229-
mediaRecorder.start();
230-
231-
});
232-
};//»
233250
const com_remux = async (term, args) => {//«
234251
235252
return new Promise(async(Y,N)=>{
@@ -395,13 +412,13 @@ return write_to_redir(term, blob, redir)
395412
396413
397414
};//»
398-
415+
*/
399416
export const coms = {//«
400-
webmcat: com_webmcat,
401-
remux: com_remux,
417+
// webmcat: com_webmcat,
418+
// remux: com_remux,
402419
record: com_record,
403-
wasm: com_wasm,
404-
walt: com_walt,
420+
// wasm: com_wasm,
421+
// walt: com_walt,
405422
};//»
406423

407424

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/97107","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/45541"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/10807","fs.js/28766","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/184061"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/8659","desk.js/217563","fs.js/66825","terminal.js/4300","three.js/3443","util.js/32614"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]
1+
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/97107","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/45577"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11288","fs.js/28766","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/184061"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/8659","desk.js/217563","fs.js/66825","terminal.js/4300","three.js/3443","util.js/32614"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]

0 commit comments

Comments
 (0)