> For the complete documentation index, see [llms.txt](https://docs.yemreak.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yemreak.com/arsiv/programming/video-uzerinden-sesi-almak---typescript---ffmpeg.md).

# Video uzerinden sesi almak - Typescript - ffmpeg

video, audio, programming, typescript, ffmpeg, code

![](https://i.imgur.com/wrCKVXX.png)

Video dosyasından sesi çıkarmak için TypeScript projesinde `fluent-ffmpeg` kütüphanesini kullanabilirsiniz. `fluent-ffmpeg`, FFmpeg komut satırı aracının bir sarmalayıcısıdır. `fluent-ffmpeg`'in çalışabilmesi için sisteminizde FFmpeg'in yüklü olması gerekmektedir. İşte bu görevi nasıl gerçekleştirebileceğiniz aşağıda adım adım anlatılmıştır:

### Adım 1: FFmpeg'i Yükle

Sisteminizde FFmpeg'in yüklü olduğundan emin olun. FFmpeg'i [FFmpeg'in resmi web sitesinden](https://ffmpeg.org/download.html) indirebilir veya Linux veya macOS kullanıyorsanız bir paket yöneticisi aracılığıyla yükleyebilirsiniz.

### Adım 2: `fluent-ffmpeg`'i Yükle

Henüz yapmadıysanız, projenize `fluent-ffmpeg` eklemek için şu komutu çalıştırın:

```shell
npm install fluent-ffmpeg
```

### Adım 3: Videodan Ses Çıkarmak için TypeScript Kodu

İşte `fluent-ffmpeg` kullanarak bir video dosyasından sesi çıkaran ve bunu bir MP3 dosyası olarak kaydeden basit bir TypeScript betiği. `tsconfig.json`'ınızın `ESNext`, `CommonJS` ve katı tip ayarları ile yapılandırıldığından emin olun.

```typescript
import ffmpeg from 'fluent-ffmpeg';

/**
 * Bir video dosyasından sesi çıkarır ve bunu bir MP3 dosyası olarak kaydeder.
 * @param videoFilePath - Video dosyasının yolu.
 * @param outputAudioPath - Çıkarılan ses dosyasının kaydedileceği yol.
 */
function extractAudioFromVideo(videoFilePath: string, outputAudioPath: string): Promise<void> {
    return new Promise((resolve, reject) => {
        ffmpeg(videoFilePath)
            .outputFormat('mp3') // Çıktı formatını mp3 olarak ayarla
            .on('end', () => {
                console.log(`Çıkarma tamamlandı: ${outputAudioPath}`);
                resolve();
            })
            .on('error', (err) => {
                console.error(`Ses çıkarma hatası: ${err.message}`);
                reject(err);
            })
            .save(outputAudioPath); // Çıktı dosya yolunu belirt
    });
}

// Örnek kullanım
const videoFilePath = 'path/to/your/video.mp4';
const outputAudioPath = 'path/to/output/audio.mp3';

extractAudioFromVideo(videoFilePath, outputAudioPath)
    .then(() => console.log('Ses çıkarma başarılı.'))
    .catch((err) => console.error(err));

```

**Önemli Notlar:**

* **FFmpeg Bağımlılığı:** Bu betik, FFmpeg'in doğru bir şekilde yüklendiğini ve sisteminizin PATH'ında erişilebilir olduğunu varsayar. Herhangi bir sorunla karşılaşırsanız FFmpeg yüklemenizi doğrulayın.
* **Tip Tanımları:** TypeScript, `fluent-ffmpeg` için tip tanımlarını bulamazsa, bunları `npm install @types/fluent-ffmpeg --save-dev` kullanarak yüklemeniz gerekebilir, varsayılan olarak mevcutsa, veya gerekliyse import üzerine bir `// @ts-ignore` yönergesi kullanabilirsiniz.
* **Hata Yönetimi:** Betik, asenkron çalışma ve hata yönetimi için Promise'leri kullanır. Hata yönetimi mantığını, uygulamanızın gereksinimlerine göre özelleştirin.

Bu adımları takip ederek, TypeScript projenizde video dosyalarından verimli ve etkili bir şekilde ses çıkarabilirsiniz.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.yemreak.com/arsiv/programming/video-uzerinden-sesi-almak---typescript---ffmpeg.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
