CodeIgniter Forums
clip an uploaded song? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: clip an uploaded song? (/thread-20381.html)

Pages: 1 2 3


clip an uploaded song? - El Forum - 07-08-2009

[eluser]newbie boy[/eluser]
my upload function works perfectly...

but my problem is how to clip an uploaded song in a particular time duration...

hope you can help me again guys...

thanks...


clip an uploaded song? - El Forum - 07-08-2009

[eluser]TheFuzzy0ne[/eluser]
http://stackoverflow.com/questions/43890/crop-mp3-to-first-30-seconds


clip an uploaded song? - El Forum - 07-08-2009

[eluser]newbie boy[/eluser]
is there a way to do it php?

like the file uploading class maybe?


clip an uploaded song? - El Forum - 07-08-2009

[eluser]TheFuzzy0ne[/eluser]
No, not to my knowledge. PHP is not an MP3/media player - that's what ffmpeg is for. Smile You wouldn't use notepad to edit a DVD, would you?


clip an uploaded song? - El Forum - 07-08-2009

[eluser]Dam1an[/eluser]
[quote author="newbie boy" date="1247067409"]is there a way to do it php?

like the file uploading class maybe?[/quote]

But even in the file uploading class, it uses a graphics library (normally GD2) for image manipulation
So you would just use PHP as a wrapper for something such as ffmpeg like fuzzy suggested


@Fuzz: I might not use notepad for DVD editing, but Notepad++ makes it so easy Wink


clip an uploaded song? - El Forum - 07-08-2009

[eluser]newbie boy[/eluser]
got ffmpeg now,

i found this code for cropping a mp3 file down to 30secs...

ffmpeg -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3

i just don't know how am i incorporate it with php...

i hope there someone who could help...

thanks guys...


clip an uploaded song? - El Forum - 07-08-2009

[eluser]Colin Williams[/eluser]
Never a bad time to brush up on your PHP functions...

Code:
exec('ffmpeg -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3');

More info at http://us.php.net/exec


clip an uploaded song? - El Forum - 07-09-2009

[eluser]newbie boy[/eluser]
Colin Williams,

like how am i gonna pass my mp3 file to that code?


clip an uploaded song? - El Forum - 07-09-2009

[eluser]Colin Williams[/eluser]
That's what the "inputfile.mp3" part of the command is for.

Consider this after your upload

Code:
$info = $this->upload->data();
$input_file = $info['full_path'];
$output_file = $info['file_path'] .'sample_'. $info['orig_name'];
$result = exec("ffmpeg -t 30 -acodec copy -i $input_file $output_file");



clip an uploaded song? - El Forum - 07-09-2009

[eluser]newbie boy[/eluser]
Colin Williams,

have done this before?

mine, doesn't save it into another filename...

it's blank...

maybe the code for this audio clipping in ffmpeg is not right or something?