Capítulo 62 de 988

Chapter 62: getWaveformPortion()

Core Idea

_Part of the @remotion/media-utils package of helper functions.

Key Concepts

  • Arguments
  • audioData
  • startTimeInSeconds
  • durationInSeconds
  • numberOfSamples
  • channel
  • outputRange
  • normalize?<AvailableFrom v="4.0.280" />

Code Examples

const audioData = await getAudioData(staticFile('music.mp3')); /* {
  channelWaveforms: [Float32Array(4410000), Float32Array(4410000)],
  sampleRate: 44100,
  durationInSeconds: 100.0000,
  numberOfChannels: 2,
  resultId: "0.432878981",
  isRemote: false
} */

const waveformPortion = await getWaveformPortion({
  audioData,
  // Will select time range of 20-40 seconds
  startTimeInSeconds: 20,
  durationInSeconds: 20,
  numberOfSamples: 10,
}); // [{index: 0, amplitude: 0.14}, ... {index: 9, amplitude: 0.79}]

console.log(waveformPortion.length); // 10
  • What it demonstrates: Usage pattern for getWaveformPortion() from the official docs.

Key Takeaways

  1. Understand arguments when working with getWaveformPortion().
  2. Understand audiodata when working with getWaveformPortion().
  3. Understand starttimeinseconds when working with getWaveformPortion().
  4. Understand durationinseconds when working with getWaveformPortion().
  5. Understand numberofsamples when working with getWaveformPortion().

Connects To

  • Cancel Render: related page in the Hooks & Data APIs section.
  • Continue Render: related page in the Hooks & Data APIs section.
  • Data Fetching: related page in the Hooks & Data APIs section.