简体   繁体   English

将音频从浏览器流式传输到具有特定 MIME 类型的 node.js 服务器

[英]Streaming audio from the browser to a node.js server with a specific MIME type

What I need: Streaming live audio from the browser to a node.js server in WAV format.我需要什么:将实时音频从浏览器流式传输到 WAV 格式的 node.js 服务器。

Sounds fairly simple - The Problem: Using getUserMedia you get the audio-stream BUT in audio/webm format.听起来很简单 - 问题:使用getUserMedia你可以得到audio/webm格式的音频流。 The node.js server is connected to a speech-to-text engine(deepspeech) which CAN ONLY process the stream in WAV format. node.js 服务器连接到语音到文本引擎(deepspeech),该引擎只能处理 WAV 格式的 stream。

What already works: I can already record a fixed length WAV audio blob (via RecorderJs ) and send that finished recording to the node.js server and get its stream from readFileSync server side.什么已经有效:我已经可以录制一个固定长度的 WAV 音频 blob(通过RecorderJs )并将完成的录制发送到 node.js 服务器并从readFileSync服务器端获取它的 stream。 Repository here (master working only).存储库在这里(仅主工作)。 But I don't have a fixed recording anymore and want to live-stream that audio continuously.但我不再有固定的录音,我想连续直播该音频。

As of now I am unsure if that is within the possibilities of node.js or any existing library.截至目前,我不确定这是否在 node.js 或任何现有库的可能性范围内。 I've looked into ffmpeg , but didn't find a way to change the encoding of a stream with that.我调查了ffmpeg ,但没有找到一种方法来改变 stream 的编码。 I was only able to change the encoding of a fixed file/blob with ffmpeg.我只能使用 ffmpeg 更改固定文件/blob 的编码。

I'd appreciate it if someone could lead me into the right direction so I know where to start.如果有人能引导我走向正确的方向,我将不胜感激,所以我知道从哪里开始。

FFmpeg is the way to go. FFmpeg 是 go 的方式。

I've looked into ffmpeg, but didn't find a way to change the encoding of a stream with that.我研究了 ffmpeg,但没有找到一种方法来改变 stream 的编码。

Use - for the input file, and - for the output file.-用于输入文件,将-用于 output 文件。 Then use STDIN/STDOUT streams on your Node.js child process.然后在您的 Node.js 子进程上使用 STDIN/STDOUT 流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM