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

VLC流脚本链失败求助:无法保存H264流至MP4

Fixing Your VLC TCP Stream Recording Script

Let's work through the issues in your script one by one to get your stream recording working properly:

1. Variable & Filename Problems

  • Initial variable mix-up: You originally used $file instead of $_file in the VLC command, which caused the empty .mp4 filename. You fixed this, but two more filename issues remain:
    • Duplicate .mp4 extension: Your $_file variable already ends with .mp4, but you added another .mp4 in the file{dst=$_file.mp4,...} part. This creates messy filenames like vidlecture_11:30:58_09_03_2020.mp4.mp4.
    • Colons in filenames: The %T date format includes colons (HH:MM:SS), which can cause parsing issues with VLC or file system quirks. Replace it with %H_%M_%S to use underscores instead.

2. Critical VLC Stream Output Syntax Error

The no sout stream modules matched for 'sout-keep' error happens because sout-keep is a global VLC parameter, not part of the --sout chain. You incorrectly included it inside the #transcode:... string. Move it outside as a separate argument to fix this.

Corrected Full Script

#!/bin/bash
# Use underscores for time to avoid problematic colons in filenames
_now=$(date +"%H_%M_%S_%d_%m_%Y")
# Define filename with single .mp4 extension
_file="vidlecture_$_now.mp4"

# Run VLC with fixed parameters: split long command for readability
vlc -vvv tcp://1.1.1.1:3000 \
  --sout="#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=file{dst=$_file,no-overwrite},dst=display}" \
  no-sout-all \
  sout-keep

Key Fix Breakdown

  • Filename cleanup: %H_%M_%S replaces %T to remove colons, and we only add .mp4 once in the $_file variable.
  • Sout parameter correction: sout-keep and no-sout-all are now standalone arguments, not part of the stream chain string. This eliminates the "stream module not found" error.
  • Readability: Added line breaks (\) to split the long VLC command into multiple lines, making it easier to debug later.

Expected Results

When you run the corrected script:

  • It will generate a clean filename like vidlecture_11_30_58_09_03_2020.mp4
  • The stream will both display and save without the "stream chain failed" error

内容的提问来源于stack exchange,提问作者Michael de Borst

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 22:02:40