I have the following code: function convert_audio($source, $format, $ffmpeg, $bitrate, $channel, $freq) { $cmd = "-acodec libmp3lame -ab $bitrate -ac $channel -ar $freq"; $org = $source; $wrong = array("å", "ä", "ö", "Å", "Ä", "Ö", "!", " "); $right = array("a", "a", "o", "A", "A", "O", "_", "_"); $new = str_replace($wrong, $right, $org); exec("$ffmpeg -i $new $cmd {$new}.$format"); if (file_exists("{$new}.$format")) { return array('audio' => "{$new}.$format"); } else { return false; } } ///// SKICKA/LADDA UPP ///// if (isset($_POST['submit'])) { $audio = $_FILES['audio']['name']; $wrong = array("å", "ä", "ö", "Å", "Ä", "Ö", "!", " "); $right = array("a", "a", "o", "A", "A", "O", "_", "_"); $new = str_replace($wrong, $right, $audio); $path = "ljud/$new"; if(move_uploaded_file($_FILES['audio']['tmp_name'], $path)){ $type = "mp3"; // format att konvertera till $ffmpeg = "ffmpeg"; // Sökväg till mappen där ffmpeg ligger $b = "128k"; // Kvalite på ljudet: 96 kb/s $c = "1"; // Kanaler (1=mono, 2=stereo) $f = "16000"; // Sample rate $convert = convert_audio($path, $type, $ffmpeg, $b, $c, $f); // Lyckades konverteringen? if ($convert) { $msg = "<b>Ljudfilen ( ". basename($convert['audio']) ." ) konverterades utan problem!</b><br /> Bitrate: $b | Kanaler: $c | Sample rate: $f<br /><br />"; } else { $msg = "Något gick fel!"; } } echo $msg; } /////////////////////////// PHP: The code above, converts/encodes all audio formats to .mp3 and changes bitrate, sample rate and so on. Now i want to convert/encode 2 .mp3-files (of the same file), during upload. One with low bitrate (demo/exampel), and another with high bitrate.
I changed it to this: if (isset($_POST['submit'])) { $audio = $_FILES['audio']['name']; $wrong = array("å", "ä", "ö", "Å", "Ä", "Ö", "!", " "); $right = array("a", "a", "o", "A", "A", "O", "_", "_"); $new = str_replace($wrong, $right, $audio); $path = "ljud/$new"; if(move_uploaded_file($_FILES['audio']['tmp_name'], $path)){ ///// LÅG ///// $type = "wav"; // format att konvertera till $ffmpeg = "ffmpeg"; // Sökväg till mappen där ffmpeg ligger $b = "64k"; // Kvalite på ljudet: 96 kb/s $c = "1"; // Kanaler (1=mono, 2=stereo) $f = "16000"; // Sample rate $convert_low = convert_audio($path, $type, $ffmpeg, $b, $c, $f); /////////////// ///// HÖG ///// $type = "mp3"; // format att konvertera till $ffmpeg = "ffmpeg"; // Sökväg till mappen där ffmpeg ligger $b = "192k"; // Kvalite på ljudet: 96 kb/s $c = "2"; // Kanaler (1=mono, 2=stereo) $f = "44100"; // Sample rate $convert_high = convert_audio($path, $type, $ffmpeg, $b, $c, $f); /////////////// } } PHP: Now i can see that two files are created, one .mp3 with high bitrate and one .wav with low bitrate. So far so good. But a third .mp3 is also created, with low bitrate. Why is that?