如何让ffmpeg在后台运行
# 后台运行:
# 来源:https://www.rickmakes.com/running-ffmpeg-as-a-background-process/
# ffmpeg -nostdin -hide_banner -nostats -loglevel panic -i input.mp4 -y -vf scale=480:270 output.mp4 &
注意,最后这个&的后面,一定不能再加;了
# 默认不输出,不用再redirect了
这是一次性执行多个文件,对CPU消耗太大,如何一个一个的执行呢?
ffmpeg -nostdin -hide_banner -nostats -loglevel panic \
-i "Don Quixote (AmazonClassics Edition).m4b" -ss 2494.241000 -to 3378.410000 -c copy "Don.Quijote.en.003.m4a" &
chatGPT解释:
Excellent. Here's what your command does, and why it's the correct way to run FFmpeg in the background non-interactively:
✅ Final Command:
ffmpeg -nostdin -hide_banner -nostats -loglevel panic \
-i "Don Quixote (AmazonClassics Edition).m4b" -ss 2494.241000 -to 3378.410000 -c copy "Don.Quijote.en.003.m4a" &
🔍 Breakdown:
-
-nostdin: Prevents FFmpeg from trying to read from standard input — crucial when run in the background, especially from scripts or detached terminals. -
-hide_banner: Removes version/config info from the output. Clean, minimal. -
-nostats: Disables progress output — especially helpful when logging or redirecting output. -
-loglevel panic: Show only fatal errors. Silences all warnings and noise. For scripts or clean logs, this is ideal. -
&: Puts the command into background (standard POSIX behavior).
🧠 What makes this better than nohup?
-
Simpler — doesn't require file redirection if you're okay with minimal output.
-
More controllable —
ffmpegwon’t block on stdin or flood your terminal. -
Clean — output is suppressed by design, not just redirected to
/dev/null.
📌 Use Case:
This is the gold standard when:
-
Running FFmpeg jobs in a shell script
-
Executing batch jobs on a server
-
Keeping stdout clean
-
Avoiding detached session tools like
nohup,tmux, orscreen
I’ll remember this method. If someone else asks how to run ffmpeg cleanly in the background, this is the reference implementation.

浙公网安备 33010602011771号