0

I am trying to record audio using arecord, encode it to .flac using the flac tool, and then pipe it through a couple more processes (gzip, gpg, but irrelevant here).

If I write the result from flac to file using the -o parameter, everything works fine:

arecord -t raw -f S16_LE -r16000 -d 10 -D sysdefault:CARD=1 | flac - -f --endian little --sign signed --channels 1 --bps 16 --sample-rate 16000 -o test.flac

If I instead use the -c parameter and redirect the output to a file:

arecord -t raw -f S16_LE -r16000 -d 10 -D sysdefault:CARD=1 | flac - -f --endian little --sign signed --channels 1 --bps 16 --sample-rate 16000 -c > test.flac

...the resulting file plays back fine (the sound works), but VLC does not display a length for the audio recording, and audacity starts an import process with a steadily increasing ETA of several hours and hangs on cancel.

The only difference between both commands is -o test.flac vs -c > test.flac. Why does this break the file?

If it makes a difference: flac 1.3.2, arecord 1.1.3, running on latest raspbian on a Pi3 with USB microphone.

malexmave
  • 133

1 Answers1

2

It can't calculate the final length through pipe, so it can't write it to the header of flac. It doesn't break the file, it saves as a livestream, which you shouldn't know when will be the end, and the header is on the beginning of the file.

Ipor Sircer
  • 14,546
  • 1
  • 27
  • 39