🍋
Menu
Audio

Codec

Codec (Coder-Decoder)

A software or hardware component that compresses (encodes) and decompresses (decodes) audio, video, or image data according to a specific algorithm, determining both the quality and file size of the compressed output.

技術的詳細

Audio codecs include lossy (MP3/LAME, AAC/FDK, Opus, Vorbis) and lossless (FLAC, ALAC, WavPack). Video codecs include H.264/AVC (most compatible), H.265/HEVC (50% better compression, patent-encumbered), VP9 (Google, royalty-free), and AV1 (Alliance for Open Media, best compression, slow encoding). A codec is distinct from a container format: MP4 is a container that can hold H.264 or H.265 video with AAC or AC-3 audio. Browser codec support varies: the MediaSource API's isTypeSupported() method tests codec availability. FFmpeg.wasm brings most codecs to the browser via WebAssembly.

```javascript
// Codec: Web Audio API example
const audioCtx = new AudioContext();
const response = await fetch('audio.mp3');
const buffer = await audioCtx.decodeAudioData(await response.arrayBuffer());
const source = audioCtx.createBufferSource();
source.buffer = buffer;
source.connect(audioCtx.destination);
source.start();
```

関連ツール

関連用語