使用FFmpeg转推M3U8至Nginx RTMP:非直播循环播放问题排查
Fixing Your FFmpeg HLS Live Re-stream Issue
Hey there, let's break down why your current command is looping recorded content instead of delivering a live stream, and how to fix it.
What's Wrong With the Original Command?
Your existing command works for converting the remote HLS stream to a local one, but it's not set up to continuously pull new live segments from the source. Once FFmpeg finishes processing the initial batch of segments it fetched from the remote playlist, it has no way to get new live content, so it falls back to looping the local segments it already created.
Corrected FFmpeg Command
Here's the adjusted command that will maintain a live re-stream instead of looping:
ffmpeg -fflags +igndts -hide_banner -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 10 -hls_allow_cache 0 -i https://ch.iptvmate.net/ec6e5689ffd6f9690102640bddd2f9e7.m3u8 -c copy -f hls -hls_time 4 -hls_flags append_list+delete_segments -hls_list_size 6 -hls_segment_filename 'hls/ch2/file%03d.ts' hls/ch2/playlist.m3u8
Key Additions Explained
Let's go over the new parameters that make this a live stream:
-reconnect 1: Enables automatic reconnection if the connection to the remote HLS source drops.-reconnect_streamed 1: Specifically tunes reconnection behavior for streaming sources (like live HLS).-reconnect_delay_max 10: Caps the wait time between reconnection attempts at 10 seconds, so you won't have long gaps if the source glitches.-hls_allow_cache 0: Disables local caching of the remote HLS playlist. This forces FFmpeg to fetch the latest playlist every time, ensuring it picks up new live segments as they're added by the source.
Quick Checks to Ensure Success
- Double-check that the
hls/ch2folder has proper read/write permissions for the user running FFmpeg. - Verify your Nginx RTMP configuration is correctly pointing to
hls/ch2/playlist.m3u8for the live stream endpoint.
内容的提问来源于stack exchange,提问作者Nk nk nk
相关产品推荐
相关产品推荐

