如何通过OBS Studio向ffserver推流?推流失败排查求助
Hey there, let’s work through this OBS-to-ffserver streaming failure together—since you already got ffserver working with other methods, we just need to get OBS’s settings aligned with what ffserver expects. Here’s a step-by-step approach to identify ffserver’s requirements and spot invalid parameters:
1. First, clarify exactly what ffserver expects
Your ffserver configuration file (usually ffserver.conf) is the single source of truth here. Open it up and look for the <Feed> and <Stream> blocks—these define all the rules for incoming streams:
- Feed path: The
<Feed>block specifies the endpoint you need to push to (e.g.,<Feed feed1.ffm>means your push URL should end with/feed1.ffm). - Required codecs: Check
VideoCodec(e.g.,h264,mpeg4) andAudioCodec(e.g.,aac,mp3) in the<Stream>block. OBS must use these exact codecs. - Container format: The
Formatfield (e.g.,flv,mpegts) tells you what container ffserver accepts. OBS’s output container must match this. - Video/audio specs: Note
VideoSize(resolution),FrameRate,VideoBitRate,AudioBitRate, andAudioSampleRate—OBS’s output settings need to mirror these values.
Also, use your working command-line push (the one that works on Windows/Linux) as a reference. For example, if you used:
ffmpeg -i input.mp4 -c:v h264 -c:a aac -f flv http://your-ffserver-ip:8090/feed1.ffm
This tells you ffserver accepts H.264 video, AAC audio, FLV container, and the push URL http://your-ffserver-ip:8090/feed1.ffm.
2. Cross-check OBS settings against ffserver’s requirements
Go through OBS’s Settings > Stream and Settings > Output to make sure every parameter matches:
- Push URL: Double-check it’s exactly the feed path from your ffserver config (e.g.,
http://your-ffserver-ip:8090/feed1.ffm—no typos, correct port, accessible IP). - Video encoding: Under Output > Video, set Encoder to the codec ffserver requires (e.g., H.264 (x264) if
VideoCodec h264is in the config). Match resolution, frame rate, and bitrate to ffserver’s specs. - Audio encoding: Under Output > Audio, set Audio Track 1’s Encoder to the required codec (e.g., AAC) and match bitrate/sample rate to ffserver’s
AudioBitRateandAudioSampleRate. - Container format: In Output > Streaming, set Output Format to match ffserver’s
Format(e.g., FLV ifFormat flv, MPEG-TS ifFormat mpegts). - Keyframe interval: ffserver’s
VideoGopSizedefines how often keyframes are sent (e.g.,VideoGopSize 30for 30fps = 1 keyframe per second). In OBS, set Keyframe Interval to this exact number, or "Auto" if you’re sure it aligns.
3. Use logs to pinpoint invalid parameters
OBS’s error logs are gold for figuring out what’s wrong—enable Advanced Log Mode first (Settings > Logging > Log Mode > Advanced), then try pushing again and check the log:
- If you see
Invalid codecorCodec not supported, OBS is using a codec ffserver doesn’t accept. Go back to the ffserver config to confirm required codecs. Connection refusedorHTTP 4xx/5xx errormeans your push URL is wrong, ffserver isn’t running, or a firewall is blocking the port.Invalid frame sizeorFrame rate mismatchindicates OBS’s video specs don’t match ffserver’sVideoSize/FrameRate.Invalid input formatmeans the container format OBS is sending doesn’t match ffserver’sFormatsetting.
Don’t forget to check ffserver’s own logs too (usually at /var/log/ffserver.log or a path defined in ffserver.conf). It will often log exactly why a stream was rejected—like "Received stream with wrong audio codec" or "Invalid video resolution".
4. Debug with ffmpeg to validate parameters
If you’re stuck, use ffmpeg to simulate OBS’s settings and test if ffserver accepts them. For example, if you think OBS is sending the wrong codec, run:
ffmpeg -f lavfi -i testsrc -c:v h264 -c:a aac -f flv http://your-ffserver-ip:8090/feed1.ffm
If this works, replicate these exact settings in OBS. If it fails, adjust the ffmpeg parameters (e.g., switch codec to mpeg4, container to mpegts) until it works—then apply those changes to OBS.
内容的提问来源于stack exchange,提问作者Dims




