Results 1 to 3 of 3
  1. #1

    anyone good with SOX?need code for fade out

    Hi All,

    I have been struggling a lot on this problem and you are my last chance.
    My users will be uploading mp3s on my server, I am trying to get all the mp3s to fade out after 1 minute or even better at the half of each song.
    I have this code:

    shell_exec('/usr/bin/sox input_file.mp3 output_file.mp3 fade t 0 200 5');

    It works well with other effect but not with fade out.
    The SOX manual says that the middle number "t 0 200 5" should be the length of the track, the last number the fade out length and the first number the fade in length but there is a problem, it is impossible for me to know the middle number in advance because others will be uploading the songs and not me, any any how to change this script in order to accept any song length?



  2. #2
    Join Date
    Sep 2008
    Keep in mind that I know nothing about SoX here.

    Apparently you can do sox -D input.mp3 to get the track length. You should be able to take that value and divide it to get the middle of the song.

    Maybe something like this?
    PHP Code:
    $length floor(shell_exec('/usr/bin/soxi -D input_file.mp3') / 2);
    shell_exec('/usr/bin/sox input_file.mp3 output_file.mp3 fade t 0 ".$length." 5'); 
    Last edited by Btcc22; 12-17-2009 at 11:33 PM.

  3. #3
    Hi Btcc22,

    Thanks for your help,

    I am going to give it a go and see if something similar to this works,

    Thanks for your great help :-)


Similar Threads

  1. ffmpeg fade out
    By bambinou in forum Programming Discussion
    Replies: 4
    Last Post: 11-22-2009, 08:21 PM
  2. fade away frames
    By hopesfall in forum Programming Discussion
    Replies: 1
    Last Post: 05-24-2008, 05:33 PM
  3. Yankees or Red Sox?
    By shotthebreeze in forum Web Hosting Lounge
    Replies: 6
    Last Post: 09-10-2006, 04:57 PM
  4. CSS Fade
    By riscphree in forum Programming Discussion
    Replies: 9
    Last Post: 12-07-2005, 06:13 AM
  5. Fade in Fade out slide show? *Link*
    By Z400Central in forum Programming Discussion
    Replies: 5
    Last Post: 11-18-2004, 12:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts