🎥 Make videos programmatically with React
docs
Jonny Burgerf36d06c42620
diff --git a/packages/docs/docs/webcodecs/TableOfContents.tsx b/packages/docs/docs/webcodecs/TableOfContents.tsxindex 546ce7cb2e..0db632fb62 100644--- a/packages/docs/docs/webcodecs/TableOfContents.tsx+++ b/packages/docs/docs/webcodecs/TableOfContents.tsx@@ -99,6 +99,13 @@ export const TableOfContents: React.FC = () => {<strong>{'getAvailableVideoCodecs()'}</strong><div>Get the video codecs that can fit in a container.</div></TOCItem>+ <TOCItem link="/docs/webcodecs/convert-audiodata">+ <strong>{'convertAudioData()'}</strong>+ <div>+ Change the format or sample rate of an <code>AudioData</code>+ object.+ </div>+ </TOCItem></Grid></div>);diff --git a/packages/docs/docs/webcodecs/convert-audiodata.mdx b/packages/docs/docs/webcodecs/convert-audiodata.mdxnew file mode 100644index 0000000000..7185f63ba8--- /dev/null+++ b/packages/docs/docs/webcodecs/convert-audiodata.mdx@@ -0,0 +1,53 @@+---+image: /generated/articles-docs-webcodecs-convert-audiodata.png+id: convert-audiodata+title: convertAudioData()+slug: /webcodecs/convert-audiodata+crumb: '@remotion/webcodecs'+---++# convertAudioData()<AvailableFrom v="4.0.288"/>++_Part of the [`@remotion/webcodecs`](/docs/webcodecs) package._++import {LicenseDisclaimer} from './LicenseDisclaimer';++<details>+ <summary>💼 Important License Disclaimer</summary>+ <LicenseDisclaimer />+</details>++Converts an [`AudioData`](https://developer.mozilla.org/en-US/docs/Web/API/AudioData) object to a new [`AudioData`](https://developer.mozilla.org/en-US/docs/Web/API/AudioData) object with a different sample rate or format, or both.++```tsx twoslash title="Converting an audio data"+import {convertAudioData} from '@remotion/webcodecs';++const audioData = new AudioData({+ data: new Int32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),+ format: 's32',+ numberOfChannels: 1,+ numberOfFrames: 10,+ sampleRate: 44100,+ timestamp: 0,+});++const newAudioData = convertAudioData({audioData, newSampleRate: 22050});++/*+{+ data: [0, 2, 4, 6, 8],+ format: 's32',+ numberOfChannels: 1,+ numberOfFrames: 5,+ sampleRate: 22050,+ timestamp: 0,+}+*/+```++## Behavior++- Rounding may occur.+- The new sample rate must be between 3000 and 768000.+- If no conversion is needed (same sample rate and format), the original `AudioData` is cloned.+- No cleanup is done on either the input or output `AudioData` (call [`close()`](https://developer.mozilla.org/en-US/docs/Web/API/AudioData/close) on them yourself).diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 06518c06ea..a9e6f07365 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -675,6 +675,7 @@ module.exports = {'webcodecs/get-default-video-codec','webcodecs/get-available-audio-codecs','webcodecs/get-available-video-codecs',+ 'webcodecs/convert-audiodata',],},{diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 1c18ce9f65..66fe6c0889 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -5937,6 +5937,15 @@ export const articles = [noAi: false,slug: 'webcodecs/convert-a-video',},+ {+ id: 'convert-audiodata',+ title: 'convertAudioData()',+ relativePath: 'docs/webcodecs/convert-audiodata.mdx',+ compId: 'articles-docs-webcodecs-convert-audiodata',+ crumb: '@remotion/webcodecs',+ noAi: false,+ slug: 'webcodecs/convert-audiodata',+ },{id: 'convert-media',title: 'convertMedia()',diff --git a/packages/docs/static/generated/articles-docs-webcodecs-convert-audiodata.png b/packages/docs/static/generated/articles-docs-webcodecs-convert-audiodata.pngnew file mode 100644index 0000000000..1c84d5ad03Binary files /dev/null and b/packages/docs/static/generated/articles-docs-webcodecs-convert-audiodata.png differ