import { createReadStream } from 'fs';
import { TGCalls, Stream } from 'tgcalls';
const tgcalls = new TGCalls();
tgcalls.joinVoiceCall = payload => {
// Somehow join voice call and get transport
return transport;
};
const audioStream = new Stream(createReadStream('audio.raw'));
const videoStream = new Stream(createReadStream('video.raw'), {
video: true,
});
// See the docs for more event types
// https://tgcallsjs.github.io/tgcalls/classes/stream.html#on
audioStream.on('finish', () => {
console.log('Audio finished streaming');
});
tgcalls.start(audioStream.createTrack(), videoStream.createTrack());
Video:
- Format:
rawvideo
- Resolution: min 640x360, max 1280x720
- FPS: 24 or what you provided in
StreamOptions
Audio:
- Format:
s16le
- Channels: 2
- Bitrate: 65K or what you provided in
StreamOptions
Video:
ffmpeg -i [input] -f rawvideo -vf scale=640:-1 -r 24 [output]
Audio:
ffmpeg -i [input] -f s16le -ac 1 -ar 65K [output]
Or both from a video input:
ffmpeg -i [input] \
-f s16le -ac 1 -ar 65K [audio_output] \
-f rawvideo -vf scale=640:-1 -r 24 [video_output]
Note: these examples are using default values of configurable options.
- gram-tgcalls: connects tgcallsjs with GramJS and makes using this library super easy.
Big thanks to @evgeny-nadymov for allowing us to use their code from telegram-react, and @Laky-64 for helping write this library!