NGINX RTMP模块无法手动控制录制,请求技术支持
Hey Pedro, let's get that manual recording control working properly for your NGINX RTMP setup. The issue with your current config is that it's still set to auto-record streams by default—here's how to adjust it step by step:
Key Issues in Your Current Config
Your recorder block uses record all manual;, which tells NGINX to target all streams for recording (even with a manual trigger). Plus, there's no explicit setting to disable automatic recording at the application level, so NGINX falls back to default behavior.
Modified Working Config
Replace your existing RTMP server block with this adjusted version:
rtmp { server { listen 1935; chunk_size 4000; notify_method get; application live { live on; hls on; hls_path /hls/; hls_fragment 20s; hls_playlist_length 60; # Disable auto-recording by default for all streams in this app record off; recorder rec { # Enable manual-only recording trigger via HTTP control API record manual; record_path /mp4/; record_suffix .flv; record_notify on; } } } }
What Changed & Why
record off;at the application level: This overrides any default recording behavior, ensuring NGINX won't start recording streams automatically when they're pushed to theliveapplication.record manual;in the recorder block: This removes the redundantallflag and explicitly tells NGINX that this recorder should only activate when triggered by your HTTP control endpoints.
Verification Steps
- Restart NGINX to apply the config changes:
sudo systemctl restart nginx # For systemd-based systems # OR sudo service nginx restart # For older init systems - Push a test stream to
rtmp://your-server-ip/live/your-stream-name—you shouldn't see any.flvfiles appearing in/mp4/automatically. - Trigger recording via your start endpoint:
https://mydomain:8080/control/record/start?app=live&name=your-stream-name&rec=rec
Check/mp4/—you should now see the recording file being created. - Stop recording with your stop endpoint:
https://mydomain:8080/control/record/stop?app=live&name=your-stream-name&rec=rec
The recording file will be finalized and saved in/mp4/.
Quick Troubleshooting Tip
If recording still doesn't work as expected, check NGINX's error log (usually located at /var/log/nginx/error.log) to ensure:
- The NGINX process has read/write permissions for the
/mp4/directory. - Your control endpoint requests are reaching NGINX (check for any 404 or permission errors in the logs).
内容的提问来源于stack exchange,提问作者Pedro

