Skip to content

AudioStream

A non-owning view of an audio stream within a Media. It wraps an AVStream + its codec parameters, owns no native memory, and holds a refcount on its parent Media so the file stays open while the view is alive.

Obtain one from Media::audioStream() or Media::streams(). Pass it to MediaEncoder::addAudio() to map it into an output.

All readonly.

PropertyTypeDescription
$indexintStream index within the container.
$codecstringCodec short name, e.g. "aac".
$durationfloatStream duration in seconds (0.0 if unknown).
$bitrateintStream bit rate in bits/sec.
$sampleRateintSamples per second, e.g. 44100.
$channelsintNumber of audio channels.
$a = FFmpeg\Media::open('clip.mp4')->audioStream();
if ($a !== null) {
printf("%s %d Hz %d ch\n", $a->codec, $a->sampleRate, $a->channels);
}

Media · VideoStream · MediaEncoder

An Artisan Build project.

Built on FFmpeg — an independent binding, not affiliated with or endorsed by the FFmpeg project.

Proudly sponsored by Tighten.