# wrtc-to-ffmpeg

> Pipe WebRTC MediaStreams to/from fluent-ffmpeg.

Latest version **0.0.0** (published 2019-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install wrtc-to-ffmpeg
pnpm add wrtc-to-ffmpeg
yarn add wrtc-to-ffmpeg
bun add wrtc-to-ffmpeg
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2019-06-09 |
| First published | 2019-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 326.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomas Mullen |
| Maintainers | rationalcoding |

## Links

- npm: https://www.npmjs.com/package/wrtc-to-ffmpeg
- npm.io page: https://npm.io/package/wrtc-to-ffmpeg

## Dependencies (2)

- [stream-chunker](https://npm.io/package/stream-chunker.md) ^1.2.8
- [fluent-ffmpeg-multistream](https://npm.io/package/fluent-ffmpeg-multistream.md) ^1.0.0

## Recent versions

- 0.0.0 (latest) — 2019-06-09

## README

# wrtc-to-ffmpeg

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Pipe MediaStreamTracks between [wrtc](https://github.com/node-webrtc/node-webrtc) and [fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg). Early development, plenty of issues. Currently only for Unix and Linux.

Allows you to record WebRTC streams, stream media files over WebRTC connections, or route WebRTC streams to RTSP/RTMP/etc. 

```javascript
const ffmpeg = require('fluent-ffmpeg')
const wrtc = require('wrtc')
const w2f = require('wrtc-to-ffmpeg')(wrtc)

const input = await w2f.input(track) // audio or video MediaStreamTrack

ffmpeg()
  .input(input.url)             // add our input
  .inputOptions(input.options)  // specify the input options
  .output('./myVideo.mp4')      // save the stream to an mp4
```

You can also pipe FFMPEG output to `MediaStreamTracks`.

```javascript
const videoOutput = await w2f.output({ kind: 'video', width: 480, height: 360 })
const audioOutput = await w2f.output({ kind: 'audio', sampleRate: 48000 })
ffmpeg()
  .input('./myVideo.mp4')  
  .output(videoOutput.url)  					
  .outputOptions(videoOutput.options) 
  .output(audioOutput.url)  					
  .outputOptions(audioOutput.options) 

videoOutput.track // do what you want with the new MediaStreamTracks
audioOutput.track
```

## API
### `input = await w2f.input(track)`

Transforms a `MediaStreamTrack` into an input object.

`input.url` is a Unix domain socket path that FFMPEG can use as input.

`input.options` is an object with the minimum FFMPEG options.

### `output = await w2f.output({ kind, width, height, sampleRate })`

Creates an output object with the specified properties.

`output.track` is a `MediaStreamTrack`.

`output.url` is a Unix domain socket path that FFMPEG can use as output.
 
`output.options` is an object with the minimum FFMPEG options.

---
_Source: https://npm.io/package/wrtc-to-ffmpeg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
