Redirect FFmpeg Error Logs to a File on macOS

This article provides a quick guide on how to capture and save FFmpeg error logs into a text file on macOS. Because FFmpeg writes its status and error messages to the standard error stream instead of the standard output stream, standard redirection techniques must be adjusted. Below, you will find the exact Terminal commands needed to redirect these logs for troubleshooting or archival purposes.

Understanding FFmpeg Output Streams

By default, FFmpeg sends its progress, warnings, and error messages to stderr (standard error, represented by the file descriptor 2) rather than stdout (standard output, represented by 1). To capture these logs in macOS Terminal, you must explicitly redirect stream 2.

Method 1: Redirect Only Error Logs (stderr)

To save only the FFmpeg log output to a file while keeping any standard command output separate, use the 2> operator.

Run the following command in Terminal:

ffmpeg -i input.mp4 output.mp3 2> ffmpeg_log.txt

This command processes your file and sends all the console log output into a new file named ffmpeg_log.txt in your current working directory. If the file already exists, it will be overwritten.

Method 2: Append Logs to an Existing File

If you are running multiple FFmpeg commands and want to accumulate logs in a single text file without overwriting previous entries, use the 2>> operator:

ffmpeg -i input.mp4 output.mp3 2>> ffmpeg_log.txt

Method 3: Redirect Both stdout and stderr

If your FFmpeg command outputs data to standard output (for example, piping video data to another tool) and you want to capture both that data and the error logs into a single file, use the following syntax:

ffmpeg -i input.mp4 output.mp3 > ffmpeg_combined_log.txt 2>&1

In modern macOS shells like Zsh, you can use this shortcut to achieve the same result:

ffmpeg -i input.mp4 output.mp3 &> ffmpeg_combined_log.txt

Method 4: Filter for Errors Only

FFmpeg outputs a large amount of configuration and progress information by default. If you only want to write actual errors to your text file, combine the redirection command with the -loglevel flag:

ffmpeg -loglevel error -i input.mp4 output.mp3 2> errors_only.txt

This reduces noise in your log file, ensuring it only contains critical failures and errors.