Run FFmpeg in the Background with nohup on Linux

Running long-running media processing tasks in Linux can be problematic if your terminal session disconnects or closes. This article provides a quick, practical guide on how to use the nohup command combined with background operators to keep your FFmpeg processes running seamlessly in the background, even after you log out.

Understanding the Command Structure

To run FFmpeg in the background and ensure it survives a terminal detachment, you need to combine nohup, the FFmpeg command itself, output redirection, and the shell’s background operator.

Here is the standard syntax to achieve this:

nohup ffmpeg -i input.mp4 output.mkv > ffmpeg.log 2>&1 &

Breaking Down the Components

Managing Your Background FFmpeg Process

Once you execute the command, the terminal will output a Process ID (PID). You can use this ID to monitor or stop the task later.

ps aux | grep ffmpeg
tail -f ffmpeg.log
kill [PID_NUMBER]