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

VLC HTTP流媒体总是10秒后中断,求解决方案及FFmpeg替代方案

Troubleshooting VLC HTTP Stream Cutting Off + FFmpeg Alternatives

First, let's tackle your VLC issue. The 10-second cut-off and subsequent "failed to find URL" error usually points to either a buffering problem, codec incompatibility, or the VLC server exiting unexpectedly. Here's how to diagnose and fix it:

Debug VLC Server with Verbose Logs

Run your server command with verbose output to see exactly what's going wrong when the stream cuts off. This will help identify errors like buffer underruns or codec failures:

vlc -vvv 1.avi :sout=#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=http{dst=:8080/test.ogg}} :sout-all :sout-keep

Look for error messages around the 10-second mark—common culprits include "buffer underrun" or codec initialization failures.

Adjust VLC Stream Settings

  • Add a muxer cache to prevent buffer underruns:
vlc 1.avi :sout=#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=http{dst=:8080/test.ogg}} :sout-all :sout-keep :sout-mux-caching=2000

The :sout-mux-caching=2000 adds a 2-second buffer (adjust to 3000 or higher if needed).

  • Switch to a more stable codec combination (H.264/AAC is widely supported and less prone to issues):
vlc 1.avi :sout=#transcode{vcodec=h264,vb=1000,acodec=mp4a,ab=128}:duplicate{dst=http{dst=:8080/test.mp4}} :sout-all :sout-keep :sout-mux-caching=2000

Then play with vlc http://localhost:8080/test.mp4.

Verify Port & File Integrity

  • Check if port 8080 is in use by another service:
sudo lsof -i :8080

If it's occupied, change the port in your command (e.g., :8081/test.ogg).

  • Test the local video file first: Play 1.avi with VLC to ensure it doesn't have corruption that causes crashes.

If You Want to Switch to FFmpeg

FFmpeg is often more reliable for streaming tasks, especially for long-running streams. Here are two solid options:

Option 1: HTTP Ogg Stream (Matching Your Original Setup)

This replicates your VLC setup but uses FFmpeg's more robust encoding pipeline:

ffmpeg -re -i 1.avi -c:v libtheora -b:v 800k -c:a libvorbis -b:a 128k -f ogg http://localhost:8080/test.ogg
  • -re ensures FFmpeg reads the video at its native frame rate (critical for smooth streaming).
  • Client command: vlc http://localhost:8080/test.ogg

Option 2: HLS Streaming (More Robust for Long Streams)

HLS (HTTP Live Streaming) is ideal for persistent streams—it breaks the video into small segments, so clients can easily reconnect if the stream drops:

  • Create a directory to store HLS segments:
mkdir hls
  • Run FFmpeg to encode and segment the stream:
ffmpeg -re -i 1.avi -c:v h264 -b:v 1000k -c:a aac -b:a 128k -f hls -hls_time 10 -hls_list_size 0 -hls_flags delete_segments ./hls/stream.m3u8
  • -hls_time 10 creates 10-second segments.
  • -hls_list_size 0 keeps all segments in the playlist (instead of limiting to a number).
  • -hls_flags delete_segments cleans up old segments to save disk space.
  • Serve the HLS directory with a simple HTTP server:
python3 -m http.server 8080 --directory ./hls
  • Client command: vlc http://localhost:8080/stream.m3u8

Note: Ensure FFmpeg is installed on your Ubuntu machine with sudo apt install ffmpeg.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:53:23