The media track to save.
If 'send', it is a local track. If 'recv', it is a remote track.
If greater than 0, the track is enabled after this time in milliseconds.
If greater than 0, the track is disabled after this time in milliseconds.
If greater than 0, the video is cropped to this x coordinate.
If greater than 0, the video is cropped to this y coordinate.
If greater than 0, the video is cropped to this width.
If greater than 0, the video is cropped to this height.
The video frame rate.
Run a simple websocket server:
const ws = require('ws')
const fs = require('fs')
const wss = new ws.Server({ port: 8080 })
wss.on('connection', (ws, req) => {
const query = req.url.split('?')[1]
const filename = new URLSearchParams(query).get('filename')
const file = fs.createWriteStream(filename)
console.log(`Saving media to ${filename}`)
ws.on('message', message => file.write(message))
ws.on('close', () => {
console.log(`done saving ${filename}`)
file.end()
})
})
Run the test:
webrtcperf.config.SAVE_MEDIA_URL = 'ws://localhost:8080'
await saveMediaTrack(videoTrack, 'send')
The file will sent to the server as Participant-000000_send_<track.id>.ivf.raw
.
Saves the media track to file. Audio tracks are saved as a raw float32 array, video tracks are saved as VP8 encoded packets in an IVF container. The file is sent to the server defined in
config.SAVE_MEDIA_URL
using a WebSocket connection.