Automatically trimming an mp3 in PHP
You could try the MP3 Class on PHPClasses. It features the following example:
require_once './class.mp3.php';
$mp3 = new mp3;
$mp3->cut_mp3('input.mp3', 'output.mp3', 0, -1, 'frame', false);
In this case, the 'frame' can be substituted with 'second' to base the cut on a time-frame.
ffmpeg being inprecise when trimming mp3 files
You can't trim MP3 (nor most lossy codec output) with that level of precision. An MP3 frame or so of padding is added during encoding. (See also: https://wiki.hydrogenaud.io/index.php?title=Gapless, and all the hacks required to make this work.)
If you need precision timing, use something uncompressed like PCM in WAV, or a lossless compression like FLAC.
Autoplay sound mp3 each one minute
Simply you can merge both sound with your timing and implemented just like this:
<audio controls="controls" onloadeddata="audioSoundFunction()">
<source src="horse.mp3" type="audio/mp3" />
</audio>
Javascript:
function audioSoundFunction() {
var audioSound = this;
setTimeout(function() {
audioSound.play();
}, 10000)
}
PHP header returning with spaces when using variables?
You should url encode and trim extra whitespace before placing in the header.
$name = rawurlencode(trim($name));
header("Content-Disposition: attachment; filename='{$name}'");
Final Solution
$name = $extract['original_name'];
$name2 = urlencode(trim($name));
$name3 = str_replace("+", " ", $name2);
$quote = '"';
header("Content-Disposition: attachment; filename=$quote{$name3}$quote");
I am pretty sure you could clean this up:
$name = $extract['original_name'];
$name = urlencode(trim($name));
$name = str_replace("+", " ", $name);
header("Content-Disposition: attachment; filename=\"{$name}\"");
And, if the urlencode does not seem to make a difference, I am pretty certain you can just do this:
$name = $extract['original_name'];
$name = trim($name);
header("Content-Disposition: attachment; filename=\"{$name}\"");
Related Topics
Transpose Multidimensional Array and Join Values with Commas
Block Specific Ip Block from My Website in PHP
Environment Driven Database Settings in Laravel
How to Run Yii2 Application on Hosting
A Restful Persistence Solution Usable with Backbone.Js... in PHP
PHP - Iterate on String Characters
Improve This PHP Bitfield Class for Settings/Permissions
Combining and Compressing Multiple JavaScript Files in PHP
Detect "Overall Average" Color of the Picture
Clean Way to Throw PHP Exception Through Jquery/Ajax and JSON
Pdo Looping Through and Printing Fetchall
How to Only Use Created_At in Laravel
Creating New Laravel Project via Composer Fails with Error Class Arrayloader Not Found
File Not Found When Running PHP with Nginx
Preparing PHP Application to Use with Utf-8
How to Add PHP Pagination in Array'S