Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h3>Record video from webcam and transcode to mp4 (x264) and play!</h3>
  <video id="webcam" width="320px" height="180px"></video>
  <video id="output-video" width="320px" height="180px" controls></video>
<button id="record" disabled>Start Recording</button>
<p id="message"></p>


                html, body {
  margin: 0;
  width: 100%;
  height: 100%
body {
  display: flex;
  flex-direction: column;
  align-items: center;


                const { createFFmpeg, fetchFile } = FFmpeg;
const ffmpeg = createFFmpeg({
  log: true,

const webcam = document.getElementById('webcam');
const recordBtn = document.getElementById('record');
const startRecording = () => {
  const rec = new MediaRecorder(webcam.srcObject);
  const chunks = [];
  recordBtn.textContent = 'Stop Recording';
  recordBtn.onclick = () => {
    recordBtn.textContent = 'Start Recording';
    recordBtn.onclick = startRecording;

  rec.ondataavailable = e => chunks.push(;
  rec.onstop = async () => {
    transcode(new Uint8Array(await (new Blob(chunks)).arrayBuffer()));

(async () => {
  webcam.srcObject = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
  recordBtn.disabled = false;
  recordBtn.onclick = startRecording;

const transcode = async (webcamData) => {
  const message = document.getElementById('message');
  const name = 'record.webm';
  message.innerHTML = 'Loading ffmpeg-core.js';
  await ffmpeg.load();
  message.innerHTML = 'Start transcoding';
  ffmpeg.FS('writeFile', name, await fetchFile(webcamData));
  await'-i', name,  'output.mp4');
  message.innerHTML = 'Complete transcoding';
  const data = ffmpeg.FS('readFile', 'output.mp4');

  const video = document.getElementById('output-video');
  video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));