0

I've searched here and online,. and have not found clear PHP examples for taking a single MP3 file, and trimming it to a smaller file (removing both beginning and end portions and retaining only the content between a specified start time and end time)..

What I'm trying to do is pass the start time, end time and mp3 file name to a PHP script, that will then use FFMPEG-PHP to effectively trim or concat that orig file.. without re-encoding it (and retaining all the orig. file metadata, etc.)

If you provide an example of how to process an MP3 file like this, within one PHP file, it will help a lot! I'm trying my best to help out our church, and simply don't know FFMPEG-PHP enough to sort this out solo.. :)

Thanks!!

hakre
  • 193,403
  • 52
  • 435
  • 836
revive
  • 831
  • 2
  • 15
  • 31
  • I'm also open to a pure PHP solution (I just came across http://www.sourcerally.net/Scripts/20-PHP-MP3-Class and will see if it'll work.. – revive Oct 25 '11 at 05:19

1 Answers1

3

I usually use Sox for my audio editing, it is a free command line tool that you can use with php with exec(); The command to crop an audio file:

$ sox input.wav output.wav trim 0 10

where 0 is the start point and 10 is the end. As far as retaining meta data, you will have to try it and let me know.

http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audio-files/

box86rowh
  • 3,415
  • 2
  • 26
  • 37
  • Very cool. I read a little about sox and when I came across the part that said it was (at times) difficult and cryptic to use.. I didn't read much more LOL. I will check into this. Is there any benefit of using sox over ffmpeg-php or is it just preferences? – revive Oct 25 '11 at 05:30
  • 1
    Just that its geared towards audio editing, mostly preference however. – box86rowh Oct 25 '11 at 05:33
  • excellent.. audio processing is what I need :) Thanks for the suggestion and responses. – revive Oct 25 '11 at 07:55