When attempting to run commands (in my case, trimming silence from beginning and end of a long file), sox uses temporary files inside /tmp/, however my /tmp/ directory is a TMPFS (memory-bound), so sox fails when processing large files:
sox -q "huge_file.flac" "trimmed.flac" silence 1 1s 1% reverse silence 1 1s 1% reverse
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: flowed asymmetrically!
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: error writing temporary file: No space left on device
Setting TMPDIR (as per this thread) doesn't change a thing.
~~~
TMPDIR=/media/storage/backup/ sox -q "huge_file.flac" "trimmed.flac" silence 1 1s 1% reverse silence 1 1s 1% reverse
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: flowed asymmetrically!
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: error writing temporary file: No space left on device
Because `lsof | grep sox` reveals that the temporary files are still inside /tmp:
sox 11950 wallex 4u REG 0,35 0 21151847 /media/storage/backup/trimmed.flac
sox 11950 wallex 5u REG 0,36 580718592 1559 /tmp/#1559 (deleted)
sox 11950 wallex 6u REG 0,36 580718592 1560 /tmp/#1560 (deleted)
sox 11950 wallex 7u REG 0,36 0 1561 /tmp/#1561 (deleted)
sox 11950 wallex 8u REG 0,36 0 1562 /tmp/#1562 (deleted)
Everything else I use in my system has ways to specify the temporal directory for cases like this, so please have sox read/use some environmental variable and please add the documentation on the manual page :)
The -V -V output of the command is:
sox: SoX v14.4.2
time: Oct 28 2023 17:52:23
issue: Gentoo
uname: Linux Zarielle 6.1.57-gentoo #1 SMP PREEMPT_DYNAMIC Sun Oct 22 14:06:17 -05 2023 x86_64
compiler: gcc 13.2.1 20230826
arch: 1288 48 88 L OMP
sox INFO formats: detected file format type `flac'
sox DBUG flac: API version 13
Input File : 'huge_file.flac'
Channels : 2
Sample Rate : 48000
Precision : 24-bit
Duration : 10:00:17.32 = 1728831488 samples ~ 2.7013e+06 CDDA sectors
File Size : 6.02G
Bit Rate : 1.34M
Sample Encoding: 24-bit FLAC
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
Comment : 'encoder=Lavf60.3.100'
sox INFO sox: Overwriting `trimmed.flac'
sox INFO flac: encoding at 24 bits per sample
Output File : 'trimmed.flac'
Channels : 2
Sample Rate : 48000
Precision : 24-bit
Sample Encoding: 24-bit FLAC
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
Comment : 'encoder=Lavf60.3.100'
sox DBUG libsox_i: tmpfile()
sox DBUG libsox_i: tmpfile()
sox DBUG libsox_i: tmpfile()
sox DBUG libsox_i: tmpfile()
sox INFO sox: effects chain: input 48000Hz 2 channels (multi) 24 bits 10:00:17.32
sox INFO sox: effects chain: silence 48000Hz 2 channels (multi) 24 bits unknown length
sox INFO sox: effects chain: reverse 48000Hz 2 channels 24 bits unknown length
sox INFO sox: effects chain: silence 48000Hz 2 channels (multi) 24 bits unknown length
sox INFO sox: effects chain: reverse 48000Hz 2 channels 24 bits unknown length
sox INFO sox: effects chain: output 48000Hz 2 channels (multi) 24 bits unknown length
sox DBUG sox: start-up time = 0.000888
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: flowed asymmetrically!
sox FAIL reverse: error writing temporary file: No space left on device
sox FAIL reverse: error writing temporary file: No space left on device
~~~
There is the
sox --temp directoryoption described in the manual.If you are on Windows you can also set TEMP or TMP but on Unix this isn't respected.
For a persistent solution, you can add
to your
~/.profile(or~/.bashrcor~/.bash_profileif you usebash- it's a bit confused about what its startup files are; addingat the start of
~/.bashrcand not having~/.bash_profileseems the best workaround)