1 year ago

#338775

test-img

John Mergene Arellano

No audio output using FFmpeg

I am having problem on Live stream output. I am streaming from mobile app to Node JS server to RTMP. Video output of the live stream is working but not the audio. There is no audio output from live stream.

From my client side, I am sending a stream using the Socket.IO library. I captured the video and audio using getUserMedia API.

navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
    window.videoStream = video.srcObject = stream;
    let mediaRecorder = new MediaRecorder(stream, {
        videoBitsPerSecond : 3 * 1024 * 1024
    });
    mediaRecorder.addEventListener('dataavailable', (e) => {
        let data = e.data;
        socket.emit('live', data);
    });
    mediaRecorder.start(1000);
});

Then my server will receive the stream and write it to FFmpeg.

client.on('live', (stream)=>{
   if(ffmpeg)
       ffmpeg.stdin.write(stream);
});

I tried watching the live video in VLC media player. There is a 5 seconds delay and no audio output.

Please see below for FFmpeg options I used:

ffmpeg = this.CHILD_PROCESS.spawn("ffmpeg", [
   '-f',
   'lavfi',
   '-i', 'anullsrc',
   '-i','-',
   '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency',
   '-c:a', 'aac', '-ar', '44100', '-b:a', '64k',
   '-y', //force to overwrite
   '-use_wallclock_as_timestamps', '1', // used for audio sync
   '-async', '1', // used for audio sync
   '-bufsize', '1000',
   '-f',
   'flv',
   `rtmp://127.0.0.1:1935/live/stream` ]);

What is wrong with my setup? I need to fix the command so that the live stream will output both video and audio.

I tried streaming to youtube RTMP but still no audio. I am expecting to have an output of video and audio from the getUserMedia API.

What is wrong with my setup? I need to fix the command so that the live stream will output both video and audio.

I tried streaming to youtube RTMP but still no audio. I am expecting to have an output of video and audio from the getUserMedia API.

ffmpeg

webrtc

rtmp

getusermedia

0 Answers

Your Answer

Accepted video resources