Skip to content
Office Open

PPTX

Media

Embed video and audio files into slides with poster images

Embed video and audio content into your presentations using the video and audio slide element types.

The data and poster fields accept raw bytes (Uint8Array, ArrayBuffer, Buffer) or a base64 data URL such as data:image/png;base64,....

#Video

ts
import { generatePresentation } from "@office-open/pptx";
JSON
{
  "slides": [
    {
      "children": [
        {
          "video": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "15.9cm",
            "height": "10.6cm",
            "data": "data:video/mp4;base64,AAAAHGZ0eXBtcDQy...",
            "type": "mp4"
          }
        }
      ]
    }
  ]
}

#Video with Poster Image

A poster image is shown before the video starts playing:

JSON
{
  "slides": [
    {
      "children": [
        {
          "video": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "15.9cm",
            "height": "10.6cm",
            "data": "data:video/mp4;base64,AAAAHGZ0eXBtcDQy...",
            "type": "mp4",
            "poster": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
            "posterType": "jpg"
          }
        }
      ]
    }
  ]
}

If no poster is provided, a minimal transparent placeholder is used automatically.

#Audio

ts
import { generatePresentation } from "@office-open/pptx";
JSON
{
  "slides": [
    {
      "children": [
        {
          "audio": {
            "x": "1.3cm",
            "y": "10.1cm",
            "width": "5.3cm",
            "height": "1.3cm",
            "data": "data:audio/mp3;base64,SUQzBAAAAAAAI...",
            "type": "mp3"
          }
        }
      ]
    }
  ]
}

#Supported Formats

#Video (type)

ValueFormat
mp4MP4
movMOV
wmvWMV
aviAVI

#Audio (type)

ValueFormat
mp3MP3
wavWAV
wmaWMA
aacAAC

#Options

#Video

PropertyTypeDefaultDescription
xnumber | UniversalMeasure0Left position (EMU or UniversalMeasure)
ynumber | UniversalMeasure0Top position (EMU or UniversalMeasure)
widthnumber | UniversalMeasure0Width (EMU or UniversalMeasure)
heightnumber | UniversalMeasure0Height (EMU or UniversalMeasure)
dataUint8Array-Video file data
type"mp4" | "mov" | "wmv" | "avi"-Video format
namestringautoDisplay name
posterUint8ArrayautoPoster image data
posterType"png" | "jpg""png"Poster image format
animationAnimationOptions-Play animation

#Audio

PropertyTypeDefaultDescription
xnumber | UniversalMeasure0Left position (EMU or UniversalMeasure)
ynumber | UniversalMeasure0Top position (EMU or UniversalMeasure)
widthnumber | UniversalMeasure0Width (EMU or UniversalMeasure)
heightnumber | UniversalMeasure0Height (EMU or UniversalMeasure)
dataUint8Array-Audio file data
type"mp3" | "wav" | "wma" | "aac"-Audio format
namestringautoDisplay name
animationAnimationOptions-Play animation

#Tips

  • Provide a poster image for videos to ensure a visual preview is shown before playback.
  • Audio frames are typically small and positioned at the bottom of a slide.
  • Media files are embedded directly into the .pptx file — keep file sizes reasonable for performance.
  • Supported playback depends on the presentation viewer (PowerPoint, Keynote, Google Slides, etc.).