Skip to content

Koodeyo-Media/wrtc-to-ffmpeg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wrtc-to-ffmpeg

JavaScript Style Guide

WORK-IN-PROGRESS - HERE BE DRAGONS

Pipe MediaStreamTracks between wrtc and 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.

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.

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.

About

Pipe WebRTC MediaStreams to/from FFMPEG.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%