Audio and Video

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

Use audio and video functions to read and write video or audio files, and also 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.

Functions

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 or recording
playPlay audio from audioplayer object
playblockingPlay audio from audioplayer object, hold control until playback completes
resume Resume playback or recording from paused state
stopStop playback or recording

Record Audio

audiorecorderObject for recording audio
getaudiodataStore recorded audio signal in numeric array
getplayerCreates 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
soundConvert matrix of signal data to sound
soundscScale data and play as sound
beepProduce operating system beep sound

Topics

Read Video Files

Read frames from a video starting at a specific time or frame index, read frames within a specified interval, or read all the frames in the video.

Convert Between Image Sequences and Video

Convert between video files and sequences of image files using VideoReader and VideoWriter.

Read and Write Audio Files

Write data to an audio file, get information about the file, and then read the data back into the MATLAB® workspace.

Record and Play Audio

Record and play audio data for processing in MATLAB from audio input and output devices on your system.

Supported Video and Audio File Formats

Video and audio files in MATLAB and their supported file formats and codecs.