6

I want to make a bunch of silent audio files (of different lengths: A few seconds up to some minutes), just to but them into playlists and so on in order to have silent times in between.

I am wondering which audio file format to use which gives smallest file size while having exact silence.

Right now, I am using FLAC with 1kHz sampling rate, mono, 16 bits bit-depth. A 60 seconds silent file such is 723 bytes big. I created it with ReZound.

On my 60 second silent file, the output of mediainfo gives:

General
Complete name                            : silence-060s.flac
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
File size                                : 723 Bytes
Duration                                 : 1mn 0s
Overall bit rate mode                    : Variable
Overall bit rate                         : 96 bps

Audio
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
Duration                                 : 1mn 0s
Bit rate mode                            : Variable
Bit rate                                 : 85 bps
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 1 000 Hz
Bit depth                                : 16 bits
Stream size                              : 637 Bytes (88%)
Writing library                          : libFLAC 1.3.1 (UTC 2014-11-25)

723 bytes filesize is already good, but comparing to the task -- just silence -- I would imagine you can encode it with just a few bytes for any lengths. You just would neet to specify the duration ... or have a bit depth of 0 bit and a sample rate of 1/duration.

But a 600s silent file is already 6.6 KiB big, the filesize scales approximately linear with the duration.

Is there any (at best free) audio file format which takes into account exact silence and can encode that in a feasible way? (OK, I might try MIDI or other sequencer-based formats, at least MIDI is not well supported on audio playback software on Linux and needs special software ...)

Golar Ramblar
  • 161
  • 1
  • 4
  • 2
    Why use lossless compression for silence? :-D You could lower the quality to an absolute minimum, use lowest bitdepth, sample rate and max compression settings – Michael Hansen Buur Apr 01 '16 at 10:43
  • @Michael Hansen Buur: With oggenc (Ogg Vorbis), I achieved 2.3 KiB minimum, with lame (mp3), I achieved 59 KiB (both on the 60 seconds silence). So, which settings do you recommend that actually do work? – Golar Ramblar Apr 01 '16 at 13:13
  • Ok, so I managed to generate a 1MB file of duration 277:46:40! Believe it or not, the format is .wav... at 8 bit mono, and a marvellous sample rate of 1 Hz. Would that count? Caveat: I can't get any program to actually play it... – leftaroundabout Apr 02 '16 at 23:08
  • @leftaroundabout: That would count. How did you do it? Just coding according to the .wav-standard by hand? I want to try (and if my software plays it). – Golar Ramblar Apr 03 '16 at 06:56
  • Setting mono output and minimum sample rate (depends on encoder) leads to good results. ffmpeg -i silence.wav -b:a 1k -ac 1 -ar 8000 -y silence.mp3. I found libfdk_aac is better than MP3. You can set -ar 1 and have ffmpeg fail, but list the allowed sample rates. – Atomic Tripod Nov 28 '23 at 17:15

1 Answers1

1

Just an idea (which needs further research): do you actually need the silence to be a file or could you just play dynamically created data? If the latter is the case, you could probably find a solution to call a program that creates a silent audio file in realtime and put that in your playlist. That way you would entirely get around the file size issues for your silence tracks. I don't know enough about Linux to know how to do this, but I am pretty sure this is possible somehow (maybe using named pipes running sox or Ffmpeg to create the silent track).

Hans Meiser
  • 193
  • 4
  • That could be an idea in principle. For the audio player it should be 'transparent', and I should not need to start some other script beforehand. So I need a file that, when it is beeing read, it actually runs some code and delivers the output. – Golar Ramblar Apr 02 '16 at 09:31
  • That's what I was thinking, sadly I don't know how to do this but hey its Linux so I bet there is a way. – Hans Meiser Apr 02 '16 at 09:37
  • Generating silence with Ffmpeg or sox seems fairly easy so maybe that's a question to pass on to superuser... – Hans Meiser Apr 02 '16 at 09:38
  • Better to http://unix.stackexchange.com/ than to http://superuser.com/. – Golar Ramblar Apr 02 '16 at 10:23
  • In any case please let us know if you find out anything elsewhere, this would also be handy for test-tone generation etc pp. – Hans Meiser Apr 02 '16 at 10:30
  • Look there: http://unix.stackexchange.com/questions/273812/have-a-file-generate-its-content-on-demand. – Golar Ramblar Apr 02 '16 at 13:54
  • NICE, following that thread I found this I.e. http://www.rubydoc.info/gems/rfusefs/1.0.3 I don't know what your favourite programming language is but there are probably similar things for other languages – Hans Meiser Apr 02 '16 at 15:02