Find the answer to your Linux question:
Results 1 to 2 of 2
mpg123 -qs "$filename" | sox -t .raw -r 44100 -swx -c 2 - -t .raw -r 44100 -sw -c 2 - >"${tempdir}/track${i}" & could some one explain the above script ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Apr 2003

    Can some one explain this script to me

    mpg123 -qs "$filename" | sox -t .raw -r 44100 -swx -c 2 - -t .raw -r 44100 -sw -c 2 - >"${tempdir}/track${i}" &

    could some one explain the above script to me.

    Thanx for reading
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Täby, Sweden
    mpg123 is an MP3 decoder. The -q specifies that it shouldn't give any unnecessary output (such as the ID3 tag and stuff), and the -s flag specifies that it should output the decoded audio stream on its standard output instead of playing it. The audio stream is then piped into sox, which is a general purpose audio converter.

    The -t .raw -r 44100 -swx -c 2 - specifies what input sox is given. -t .raw indicates that it is raw input (ie. no header or the like), -r 44100 specifies that the input has a sample rate of 44100 Hz, -c 2 indicates that the input has two channels (ie. stereo). -w indicates that each sample is two bytes (w as in word, not that words are 16 bits on modern computers, but anyway), -s that the samples are signed (ie. the most significant bit indicates if the sample is "negative" or not), and -x indicates that the bytes should be swapped. The single - indicates that the input comes on the standard input stream. It can otherwise be a file name from which to take the input.
    The -t .raw -r 44100 -sw -c 2 - specifies which output sox will produce. The only difference is the absence of -x, so that the bytes don't get swapped back. The - indicates to give the output on standard output.

    >"${tempdir}/track${i}" indicates how the shell should redirect the standard output stream.

    The ampersand is just to specify that the process should be run in the background (ie. not making the shell wait for it to complete).

Posting Permissions

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