p5 record a videop5 錄成影片
startRecording() saves the canvas and the sketch's own sound as one video, MP4 where the browser can write it; ⏺ and 📷 in the 🎹 panel need no code.startRecording() 把畫布連同草圖自己的聲音錄成一支影片(瀏覽器能錄 MP4 就是 MP4)。🎹 面板上的 ⏺ 和 📷 不寫程式也能用。
Try these three things試試這三件事
- Click the page once for sound, then play A S D F G H J K over the drums.
- Press R to start recording and R again to stop: the video downloads, and a card says its length, its size and whether it has sound.
- Press P (or 📷 in the 🎹 panel) to save the canvas alone as a PNG.
- 點一下畫面就有聲音,然後跟著鼓用 A S D F G H J K 彈。
- 按 R 開始錄,再按一次 R 停:影片會下載,卡片寫出長度、大小、有沒有聲音。
- 按 P(或 🎹 面板上的 📷),只把畫布存成一張 PNG。
No hardware needed. QWERTY keys · On-screen controller · Drum machine.不需要硬體。電腦鍵盤、螢幕上的控制器、鼓機。
Read these lines讀這幾行
sketch.js:17–18 Drums and a plucked synth: both go into the video.鼓機和撥奏的合成器:兩個都會錄進影片。sketch.js:55–58 R starts and stops a take; startRecording(10) would stop by itself after ten seconds.R 開始、再按一次停止。寫 startRecording(10) 就是錄 10 秒自動停。sketch.js:73–75 recordingSaved(info): the file's name, length, size and format, once it is saved.recordingSaved(info):存好之後拿到檔名、長度、大小和格式。
In the docs文件裡: Recording: a video with its sound錄影:畫面和聲音一起錄
Next: 10 Record →下一個:10 演出影片 →
All examples所有範例