Audio with first 30 seconds mute

Asked

Viewed 82 times

0

I am having use this code more unsuccessfully but on the terminal works perfectly what can be?

exec("ffmpeg -i musica.mp3 -af "volume=enable='between(t,0,30)':volume=0" result.mp3 2> log.txt"); 

The music is in the php folder, including using other commands in the files successfully. The server is linux, the command runs perfectly by the Putty terminal. but needed to run by php.

1 answer

1


There is a strange error, I do not know how there was no syntax error, but here you used quotes inside the quotes of the first argument of exec:

... -af "volume=enable='between(t,0,30)':volume=0" ...
        ^ - Aqui                                 ^ aqui

You must escape them like this:

exec("ffmpeg -i musica.mp3 -af \"volume=enable='between(t,0,30)':volume=0\" result.mp3 2> log.txt"); 

I also recommend using escapeshellarg with the exec (if it is Like-Unix) and use the absolute path for precaution.

Should stay like this:

//Pega o caminho todo do script atual
define('FULL_PATH', rtrim(strtr(dirname(__FILE__), '\\', '/'), '/') . '/');

$sourcePath = FULL_PATH . 'musica.mp3';
$savePath   = FULL_PATH . 'result.mp3';
$params     = escapeshellarg('"volume=enable=\'between(t,0,30)\':volume=0"');

exec('ffmpeg -i ' . $sourcePath . ' -af ' . $params . ' ' . $savePath . ' 2> log.txt');
  • 1

    William you are 10 guy... worked perfectly... thank you very much...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.