Audioread Bug with Opus (maximum value returned exceeding 1)
Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights.Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights. Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights. audio, bug, audioread MATLAB Answers — New Questions