Generate a loudnorm conversion log file by appending -loglevel verbose to your FFmpeg command and redirecting the output to a text file using shell redirection operators. This approach captures detailed metadata and normalization statistics, allowing you to analyze audio levels for compliance or quality assurance without altering the final media file.
Understanding Loudnorm Metadata Output
Theloudnorm filter in FFmpeg is designed to measure and normalize audio loudness according to specific standards like EBU R128. By default, when you apply this filter, FFmpeg prints summary statistics to the standard error stream. These statistics include integrated loudness (I), loudness range (LRA), threshold (THRESH), and target offset (OFFSET). Accessing this data is crucial for two-pass normalization, where the first pass measures the audio and the second pass applies the calculated corrections. Without capturing these logs, you cannot accurately determine the parameters needed for consistent audio leveling across multiple files.
To ensure these metrics are available for analysis, you must instruct FFmpeg to output verbose logging information. The standard output usually contains warnings and errors, while the loudnorm statistics appear in the error stream. Therefore, separating or capturing both streams ensures you do not miss critical diagnostic data. This process is identical whether you are working on a Linux distribution or a Windows environment, though the syntax for file redirection differs slightly between operating systems.
For users who frequently convert large batches of media, seeing this data in real-time can clutter the terminal. Redirecting the output to a dedicated log file allows you to review the results later or parse them programmatically. This method is particularly useful when integrating FFmpeg into larger automation scripts, as seen in workflows for converting video for specific devices like iPhones, as discussed in our guide on FFmpeg on Linux - Convert Video to Play on iPhone [Solved].
Step-by-Step Guide for Linux Users
On Linux systems, you can capture the loudnorm log by combining your conversion command with shell redirection operators. The primary goal is to send the standard error stream, which holds the loudnorm statistics, to a text file while keeping the standard output visible or discarding it if unnecessary. Use the following structure for your command:ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 -loglevel verbose 2> loudnorm.log
In this command, -i input.mp3 specifies your source audio file. The -af flag applies the loudnorm filter with specific targets: Integrated loudness at -16 LUFS, True Peak at -1.5 dBTP, and Loudness Range at 11 LU. The -loglevel verbose argument ensures that all internal processes, including the loudnorm measurement, are printed. The crucial part is 2> loudnorm.log, which redirects file descriptor 2 (standard error) to a file named loudnorm.log.
After the conversion completes, open loudnorm.log with any text editor. You will see lines starting with [Parsed_loudnorm_0 @ ...] followed by the JSON-like block containing the measured values. If you also want to capture standard output (warnings) into the same file, use >> loudnorm.log 2>&1 instead. This merges both streams into one comprehensive log.
Step-by-Step Guide for Windows Users
Windows PowerShell and Command Prompt handle stream redirection differently than Unix shells. In PowerShell, you can use theStart-Transcript cmdlet or direct redirection. For simple script-based logging, direct redirection is more efficient.
Open PowerShell and run the following command:
ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 -loglevel verbose 2> loudnorm.log
PowerShell supports the 2> syntax similarly to Bash, directing standard error to the specified file. If you are using an older version of PowerShell or CMD, you might need to use cmd /c "ffmpeg ... 2> loudnorm.log" to ensure proper interpretation of the redirection operator.
Alternatively, you can use the tee utility if installed via Git Bash or WSL within Windows. This allows you to view the log in real-time while saving it. However, native PowerShell redirection is generally sufficient for generating static logs for analysis. This technique is equally applicable when dealing with complex audio conversions, such as those required for specific hardware like the aDB RX90/91, as detailed in Convert Audio to RTP with FFmpeg for aDB RX90/91.
Analyzing the Log File Content
Once the log file is generated, you need to extract the relevant data. The loudnorm filter outputs a block that resembles JSON but is embedded in verbose text. Look for the section labeledParsed_loudnorm_0. Inside this block, you will find four key metrics:
- Input Integrated: The average loudness of the source material.
- Input Threshold: The point below which audio is considered silent or negligible.
- Input LRA: The dynamic range of the audio.
- Input True Peak: The maximum instantaneous peak level.
I=-20 parameter in your second pass command to match the original dynamics more closely, rather than forcing a generic -16 LUFS target. This two-pass method prevents over-compression and preserves the artistic intent of the audio.
If you encounter issues where no log is generated, verify that your FFmpeg version is up to date. Older versions may not support the verbose loudnorm output correctly. Additionally, ensure that the path specified in the redirection command has write permissions. On Linux, check directory ownership; on Windows, ensure you are running the terminal with appropriate privileges if writing to system directories.
For troubleshooting other common FFmpeg issues, such as missing audio tracks during conversion, refer to our article on Fixing FFmpeg: No Audio when Converting DVD VOB to MP4. This often helps isolate whether the problem lies with the codec selection or the stream mapping rather than the logging mechanism itself.
Frequently Asked Questions
Why is my loudnorm log empty?
An empty log typically indicates that the -loglevel verbose flag was omitted or that the redirection operator failed due to permission issues. Ensure you are targeting file descriptor 2 for standard error, as loudnorm statistics are not sent to standard output by default.
Can I use the log file for automated processing?
Yes, the log contains structured data that can be parsed by scripts using tools like grep or awk. You can extract the integrated loudness value and feed it directly into the next FFmpeg command for two-pass normalization, creating a fully automated workflow.
Does loudnorm work on multi-channel audio?
The loudnorm filter analyzes each channel independently unless you use the print_format=json option combined with specific matrix mixing settings. It is best practice to downmix to stereo before applying loudnorm if you require a single unified loudness measurement for the entire track.
What is the difference between I, LRA, and TP?
I stands for Integrated Loudness, representing the overall perceived volume. LRA is Loudness Range, measuring the dynamic variation between quiet and loud sections. TP is True Peak, indicating the absolute maximum sample value to prevent clipping during digital-to-analog conversion.
How do I fix "Permission denied" errors on Linux?
This error occurs when the user running the FFmpeg command lacks write access to the target directory. Use chmod to adjust folder permissions or specify a writable location like /tmp/loudnorm.log for testing purposes.