Skip to content

A JavaScript library for interacting with the Telegram group voice calls API.

License

Notifications You must be signed in to change notification settings

tgcallsjs/tgcalls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tgcallsjs

npm Mentioned in Awesome Telegram Calls

Example

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());

Required media properties

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

Conversion with FFmpeg

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.

Related projects

Credits

Big thanks to @evgeny-nadymov for allowing us to use their code from telegram-react, and @Laky-64 for helping write this library!

About

A JavaScript library for interacting with the Telegram group voice calls API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published