Why can't I capture the verbose output from soxi?

45 Views Asked by At

I'm trying to get the loop start and end point metadata from an audio sample. I'm using soxi with the -V verbose flag. The data I need shows up in the terminal but isn't captured, nor piped to the next command.

Showing the data with soxi:

$ soxi -V sample.aif

soxi INFO formats: detected file format type `aiff'
soxi INFO aiff: AIFF Loop markers:
soxi INFO aiff: Loop 0: start:  75576
soxi INFO aiff:  end:   103868
soxi INFO aiff:  count:      1
soxi INFO aiff:  type:  
soxi INFO aiff: forward
soxi INFO aiff: Unity MIDI Note: 52
soxi INFO aiff: Low   MIDI Note: 50
soxi INFO aiff: High  MIDI Note: 53

Input File     : 'sample.aif'
Channels       : 1
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:03.80 = 167665 samples = 285.145 CDDA sectors
File Size      : 507k
Bit Rate       : 1.07M
Sample Encoding: 24-bit Signed Integer PCM

But when I pipe that output into a text file the top section still appears in the terminal and only the bottom section is piped to the text file:

$ soxi -V sample.aif >> data.txt

soxi INFO formats: detected file format type `aiff'
soxi INFO aiff: AIFF Loop markers:
soxi INFO aiff: Loop 0: start:  75576
soxi INFO aiff:  end:   103868
soxi INFO aiff:  count:      1
soxi INFO aiff:  type:  
soxi INFO aiff: forward
soxi INFO aiff: Unity MIDI Note: 52
soxi INFO aiff: Low   MIDI Note: 50
soxi INFO aiff: High  MIDI Note: 53

$ cat data.txt

Input File     : 'sample.aif'
Channels       : 1
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:03.80 = 167665 samples = 285.145 CDDA sectors
File Size      : 507k
Bit Rate       : 1.07M
Sample Encoding: 24-bit Signed Integer PCM

Why can't I capture that top section of output, which contains the data I need?

1

There are 1 best solutions below

2
lambda-larry On BEST ANSWER

The -V parameter of soxi outputs the verbose part to stderr (fd 2)

To include the verbose part as well, redirect stderr to stdout (fd 1)

$ soxi -V sample.aif 2>&1 | tee -a data.txt