문제

I'm working on a headless device to play music, and I'm using Sox's play command to play the file.

I'm after a way to pipe the output formatted like this:

$play File.wav

File.wav:

File Size: 1.25M
Bit Rate: 64.0k Encoding: Unsigned PCM Channels: 1 @ 8-bit Samplerate: 8000Hz Replaygain: off Duration: 00:02:36.87 In:42.4% 00:01:06.56

[00:01:30.31] Out:532k [ -===|===- ] Clip:0

To be readable in a text file so it can be parsed by PHP and ouputted to the user.

I've tried the standard things like:

$play File.wav >> output.txt

which results in a file being created but an empty one, I don't need it to be realtime, just every few seconds, or even once per run just to check it's going ok.

Any ideas?

도움이 되었습니까?

해결책

Try the following (it would appear that sox outputs on STDERR):

play File.wav >> output.txt 2>&1

Whether it's going to be easy to parse is a different story ... :)

Namely the

[00:01:30.31] Out:532k [ -===|===- ] Clip:0

bit gets broken up over individual lines with your redirect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top