Main Content

Audio and Video Data

Read and write video and audio files; Record and play audio

Read or write video or audio files, and record and play audio using your system's input and output devices.

  • Read or write video files by creating video objects. The video object contains information about the video file and enables you to read, analyze, and write video data.

  • Read or write audio data from files into arrays using the audio read and write functions.

  • Record or play audio files in with your system's input (microphone) and output devices (speakers) by using the audio recorder and player objects.

See Supported Video and Audio File Formats.

Live Editor Tasks

Import DataImport data from a file in the Live Editor (Since R2023a)


expand all

Read Video Data

VideoReaderCreate object to read video files
readRead one or more video frames
readFrameRead next video frame
hasFrameDetermine if video frame is available to read
getFileFormatsFile formats that VideoReader supports
mmfileinfoInformation about multimedia file

Write Video Data

VideoWriterCreate object to write video files
openOpen file for writing video data
writeVideoWrite video data to file
closeClose file after writing video data
getProfilesProfiles and file formats that VideoWriter supports
audioreadRead audio file
audiowriteWrite audio file
lin2muConvert linear audio signal to mu-law
mu2linConvert mu-law audio signal to linear
audioinfoInformation about audio file

Play Audio

audioplayerObject for playing audio
isplayingDetermine if playback is in progress
pausePause playback of audioplayer object or recording of audiorecorder object
playPlay audio from audioplayer object
playblockingPlay audio from audioplayer object; hold control until playback completes
resume Resume playback of audioplayer object or recording of audiorecorder object from paused state
stopStop playback of audioplayer object or recording of audiorecorder object

Record Audio

audiorecorderObject for recording audio
getaudiodataStore recorded audio signal in numeric array
getplayerCreate associated audioplayer object
isrecordingDetermine if recording is in progress
recordRecord audio to audiorecorder object
recordblockingRecord audio to audiorecorder object; hold control until recording completes

Play Sound

audiodevinfoInformation about audio device
audiodevresetRefresh list of available audio devices (Since R2020b)
soundConvert matrix of signal data to sound
soundscScale data and play as sound
beepProduce operating system beep sound