You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用FFmpeg将带音频的RTSP流推送至RTMP服务器?

Troubleshooting Audio Issues When Pushing RTSP to Facebook RTMP with FFmpeg

Hey there, let's work through this audio problem you're facing. You mentioned local playback of your camera's RTSP stream works perfectly, but when pushing to Facebook's RTMP server via FFmpeg, the audio doesn't come through. Based on your setup (Ubuntu 16.04 LTS, FFmpeg 2.8.11), here are targeted fixes to try:

1. Enforce Facebook-Compatible Audio Encoding

Facebook's RTMP endpoint requires AAC-LC audio as a standard. Your older FFmpeg version might not default to this codec, or could be using an unsupported variant. Explicitly define audio parameters in your push command:

ffmpeg -i rtsp://your-camera-rtsp-url -c:v libx264 -preset medium -crf 23 \
  -c:a aac -b:a 128k -ar 44100 -ac 2 \
  -f flv rtmp://facebook-stream-url
  • -c:a aac: Forces AAC encoding, which Facebook natively supports
  • -ar 44100: Sets audio sample rate to 44.1kHz (Facebook's recommended value)
  • -ac 2: Ensures stereo audio, the expected format for most live streams

2. Confirm FFmpeg is Detecting the RTSP Audio Stream

Even if local playback works, FFmpeg might not be correctly capturing the audio stream from the RTSP feed. Run this test command to verify:

ffmpeg -i rtsp://your-camera-rtsp-url -vn -acodec copy -f null -

Look for lines in the output describing the audio stream (e.g., Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s). If no audio stream is detected, add -map 0:a:0 to your push command to explicitly tell FFmpeg to capture the first audio stream.

3. Upgrade FFmpeg to a Newer Version

FFmpeg 2.8.11 is quite outdated (released in 2017) and lacks critical bug fixes, codec improvements, and RTMP compatibility updates that Facebook now requires. To upgrade on Ubuntu 16.04:

sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt update && sudo apt install ffmpeg

Newer versions (like the 4.x series) handle modern RTMP requirements far better, and this alone often resolves audio transmission issues.

4. Scan Your FFmpeg Log for Audio Errors

Even without access to your log file, look for keywords that point to audio failures:

  • audio codec not supported
  • could not write audio packet
  • invalid audio parameters
    These messages will directly tell you where the audio processing or transmission is breaking down.

Give these steps a try, starting with upgrading FFmpeg—old versions are a frequent culprit for RTMP compatibility problems. Let me know if any of these fix your audio issue!

内容的提问来源于stack exchange,提问作者Emiliano Spada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:12:46