livekit / ingress

Ingest streams (RTMP/WHIP) or files (HLS, MP4) to LiveKit WebRTC
Apache License 2.0
66 stars 24 forks source link

Audio streaming via ffmpeg produces choppy playback on Android devices #115

Closed Parfyonator closed 6 months ago

Parfyonator commented 1 year ago

Hello

I have an issue when using Ingress for audio streaming to a room with ffmpeg. I have two backends

Frontend is written in Flutter/Dart and uses livekit flutter SDK of the latest version (1.3.4). Flutter version: 3.7.12

When I spawn ffmpeg process to strem music to previously generated rtmp URL with this code (Node.js)

const ffmpeg = childProcess.spawn(
    `ffmpeg`, [`-re`, `-ss`, `${toHHMMSS(req.body.seekSeconds)}`, `-stream_loop`, `-1`, `-i`, `${concat}`, `-c:v`, `libx264`, `-c:a`, `aac`, `-f`, `flv`, `${req.body.rtmpUrl}`],
    {
        cwd: process.cwd() + '/songs'
    }
);

it looks like some parts of a song are dropping and it becomes choppy (watch the attached video). This behaviour happens only on Android devices: it works fine in example Web app and iOS build of my Flutter application. Snipper comment: toHHMMSS transforms transforms seconds to MM:SS format and concat is a list of mp3 files for playback.

https://github.com/livekit/ingress/assets/27166027/41c9c518-9c23-4068-8396-ba043a55e471

Parfyonator commented 1 year ago

Hi. I managed to find a solution to a problem. I switched -c:a from aac to mp3 and added -vbr 5. And now everything works fine for all platforms.

biglittlebigben commented 1 year ago

Have you tried with the libfdk_aac encoder?