How to optimize recording feature with mediasoup?

I am using Mediasoup for video conference call and now i have add ffmpeg for recording feature.

Ffmpeg code below

get _commandArgs() {
    let commandArgs = [
        '-loglevel', 'debug',
        '-report',
        '-protocol_whitelist', 'file,pipe,udp,rtp',
        '-fflags', '+genpts',
        '-flags', 'low_delay',
        '-f', 'sdp',
        '-i', 'pipe:0',
        '-rtbufsize', '256M',
        '-muxdelay', '2.0',
        '-max_delay', '12000000',
        '-reorder_queue_size', '200',
        '-flush_packets', '1',
        '-vsync', '2',
        '-threads', '12'
    ];

    // Add video and audio arguments
    commandArgs = commandArgs.concat(this._videoArgs);
    commandArgs = commandArgs.concat(this._audioArgs);

    // Add output file path
    commandArgs.push(`${this._path}/${this._fileName}`);

    return commandArgs;
}

get _videoArgs() {
    return [
        '-map', '0:v:0',
        '-c:v', 'libx264',
        '-preset', 'veryfast',
        '-crf', '23',
        '-pix_fmt', 'yuv420p',
        '-r', '30',
        '-b:v', '1M',
        '-filter:v', 'fps=fps=30',
    ];
}

get _audioArgs() {
    return [
        '-map', '0:a:0',
        '-c:a', 'aac',
        '-b:a', '128k',
        '-ar', '48000',
        '-ac', '2',
    ];
}

with current code recording works fine, lets suppose 10 users in call but with some user recording get stuck after some time .

I have seen call record report for every users the users who’s video get stuck got below an error.

dropping old packet received too late

Delay between the first packet and last packet in the muxing queue is
10016000 > 10000000: forcing output

One more question just for sake of information does this way to record video is scale-able?

All the questions about problems using ffmpeg with mediasoup are in fact questions about ffmpeg, but for whatever reason they are always thrown here in the mediasoup forum as if ffmpeg was a perfect software and whatever that fails when using it is related to other pieces of software.

1 Like