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

使用FFmpeg保存UDP组播流至文件时遇Invalid UE golomb code报错

Fixing FFmpeg "Invalid UE golomb code" Freeze When Capturing UDP Multicast

Let's break down your problem and walk through practical fixes step by step. The Invalid UE golomb code error points to corrupted H.264/H.265 bitstream data (UE golomb codes are part of the video codec's entropy encoding), and this corruption is almost certainly what's causing FFmpeg to freeze after a few minutes. The unknown SEI type 229 warning is less critical—it just means the stream has a custom SEI (Supplemental Enhancement Information) frame that FFmpeg doesn't recognize, but this shouldn't be the root cause of the freeze.

Potential Fixes

1. Mitigate UDP Multicast Packet Loss & Corruption

UDP multicast is inherently prone to packet loss and out-of-order delivery, which can corrupt the video stream. Add these robustness parameters to your UDP input:

ffmpeg -i "udp://238.0.0.1:1234?buffer_size=10485760&reorder_queue_size=1024&max_delay=500000" -c copy -f segment -segment_time 900 -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 $datestamp.mp4 -report
  • buffer_size=10485760: Boosts the UDP receive buffer to 10MB, reducing the chance of buffer overflow and lost packets.
  • reorder_queue_size=1024: Lets FFmpeg reorder out-of-order packets before processing, which addresses common multicast delivery quirks.
  • max_delay=500000: Sets a 500ms maximum delay to wait for out-of-order packets before proceeding, balancing latency and stream integrity.

2. Force FFmpeg to Ignore Bitstream Errors

Tell FFmpeg to skip corrupted frames instead of freezing up by adding error-handling flags:

ffmpeg -err_detect ignore_err -fflags +genpts+igndts -i "udp://238.0.0.1:1234" -c copy -f segment -segment_time 900 -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 $datestamp.mp4 -report
  • -err_detect ignore_err: Makes FFmpeg ignore bitstream errors and continue processing rather than halting.
  • -fflags +genpts+igndts: Generates new presentation timestamps (PTS) if the stream's timestamps are missing or corrupted, preventing timing-related freezes.

3. Re-encode the Stream Instead of Copying

If the source stream has persistent corruption, using -c copy (stream copy) will propagate the corruption and cause FFmpeg to choke. Re-encoding lets FFmpeg discard invalid frames entirely:

ffmpeg -i "udp://238.0.0.1:1234" -c:v libx264 -crf 23 -c:a aac -b:a 128k -f segment -segment_time 900 -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 $datestamp.mp4 -report
  • -c:v libx264: Re-encodes the video with the standard H.264 codec, which automatically skips unreadable frames.
  • -crf 23: Sets a balanced video quality level (adjust between 18-28 for better/worse quality as needed).
  • -c:a aac -b:a 128k: Re-encodes audio to AAC for broad compatibility.

4. Verify the Source Stream & Network

  • Test the multicast stream with another player (like VLC) to see if it also glitches or freezes—this will confirm if the issue is with the source or your FFmpeg setup.
  • Use tcpdump to check for excessive packet loss or malformed traffic:
    tcpdump -i eth0 udp port 1234 and host 238.0.0.1
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 10:03:43