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

如何用FFmpeg与Linux VPS边转码蓝光视频边通过VLC播放并保存文件?

Solution: Transcode to YouTube 720p with FFmpeg + Real-Time VLC Preview

Got it, let's tackle this step by step—you need to transcode your Blu-ray phoenix.mkv to YouTube-friendly 720p, with mono AAC audio, plus real-time preview via VLC, and fix the earlier issues of poor quality and missing output files. Here's a complete, tested solution:

1. Full FFmpeg Command (Save File + Stream for VLC)

Run this on your Linux VPS—it handles both saving the final file and streaming for live preview:

ffmpeg -i phoenix.mkv \
  # Video settings optimized for YouTube 720p
  -c:v libx264 -preset medium -crf 23 \
  -vf "scale=1280:720,format=yuv420p" \
  -profile:v high -level 4.1 \
  # Audio settings: mono, libfaac, 112kbps
  -c:a libfaac -ac 1 -b:a 112k \
  # Output to both file and UDP stream for preview
  -map 0 -f tee "[f=mp4]output.mp4|[f=mpegts]udp://0.0.0.0:1234"

Breakdown of key parameters:

  • -i phoenix.mkv: Points to your input Blu-ray file
  • Video tweaks:
    • libx264: YouTube's preferred video codec for maximum compatibility
    • -preset medium: Balances encoding speed and compression efficiency (use fast if your VPS CPU is weak, slower if you want better quality/smaller file size)
    • -crf 23: Constant Rate Factor for consistent quality—23 is the sweet spot; adjust down to 18 for higher quality or up to 28 for smaller files (YouTube recommends 18-28)
    • scale=1280:720,format=yuv420p: Scales to 720p and ensures compatibility with YouTube (YUV420p is required for most players/platforms)
    • -profile:v high -level 4.1: Ensures the video meets H.264 standards for smooth 720p playback
  • Audio tweaks:
    • libfaac: Specifies the AAC codec you requested
    • -ac 1: Forces mono audio output
    • -b:a 112k: Sets the audio bitrate to 112kbps
  • Dual output:
    • [f=mp4]output.mp4: Saves the final transcoded file to output.mp4
    • [f=mpegts]udp://0.0.0.0:1234: Streams the transcoded feed over UDP port 1234 (for VLC preview)

2. Preview with Local VLC

On your local machine, follow these steps to watch the live transcoded feed:

  1. Open VLC
  2. Go to Media > Open Network Stream
  3. Paste udp://<YOUR_VPS_IP>:1234 (replace <YOUR_VPS_IP> with your VPS's public IP address)
  4. Click Play—you’ll see the live feed while the final file saves in the background on your VPS

3. Fixing Your Earlier Issues

  • Poor quality: Your previous attempt likely missed critical settings like crf, profile:v, or format=yuv420p. The command above ensures YouTube-optimized quality without unnecessary over-compression.
  • No saved file: The -f tee muxer handles both streaming and file output simultaneously, so you won’t lose the final file while previewing.

4. Quick Troubleshooting

  • If libfaac isn’t available on your VPS: Some FFmpeg builds don’t include it. Swap in libfdk_aac (higher quality) with -c:a libfdk_aac -ac 1 -b:a 112k, or use the built-in AAC codec with -c:a aac -ac 1 -b:a 112k -strict experimental.
  • VLC can’t connect? Make sure your VPS firewall allows UDP traffic on port 1234 (run ufw allow 1234/udp if using UFW).
  • Slow transcoding? Lower the preset to fast or ultrafast—it’ll trade a tiny bit of quality for speed on weaker VPS CPUs.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:50:15