Tormy Van Cool
Tormy Van Cool

Reputation: 801

ffmpeg loudness doesn't return any file

I'm using a shared server managed by Aruba.it It uses

ffmpeg version 4.1
built with gcc 4.8.5
(GCC) 20150623
(Red Hat 4.8.5-36)

I need to use ffmpeg to fix the loudness of any uploaded MP3 to -12 dB LUFS -1 dB TP

I found on internet the following commands, but not any output.mp3 is generated

PHP

exec("/usr/bin/ffmpeg -i Temp.mp3 -af loudnorm=I=-12:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -y output.mp3");

Where do I wrong please?

EDIT Not any error is returned.

Upvotes: 0

Views: 234

Answers (3)

Tormy Van Cool
Tormy Van Cool

Reputation: 801

Based on the suggestion by @llogan I found the solution. It should be in 3 steps and not in only one. The MP3 to MP3 doesn't work, on my case. So I converted the input MP3 into wave, normalized it, and converted back to MP3

exec("/usr/bin/ffmpeg -i Temp.mp3 Temp.wav");
exec("/usr/bin/ffmpeg -i Temp.wav -af loudnorm=I=-12:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11.04:measured_thresh=-40.21:offset=-0.47 output.wav");
exec("/usr/bin/ffmpeg -i output.wav -ab 320k output.mp3");

this solution worked perfectly

Upvotes: 1

llogan
llogan

Reputation: 134063

If you run it manually, unscripted in your terminal you will get an error:

Unable to find a suitable output format for '04:measured_thresh=-40.21:offset=-0.47'
04:measured_thresh=-40.21:offset=-0.47: Invalid argument

There is an errant space in your command, so change measured_tp=-11 04 to measured_tp=-11.04.

Upvotes: 1

Andrei Lupuleasa
Andrei Lupuleasa

Reputation: 2762

With shell_exe or exec use:

$output = shell_exec('/usr/bin/ffmpeg -i Temp.mp3 -af loudnorm=I=-12:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -y output.mp 2>&1');

2 refers to the second file descriptor of the process, i.e. stderr.

> means redirection.

&1 means the target of the redirection should be the same location as the first file descriptor, i.e. stdout.

In $output you will have the response. If the apache user www-data doesn't have enough rights execute the comand as sudo

Upvotes: 0

Related Questions