summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2024-02-13 19:18:57 +0200
committerGitHub <noreply@github.com>2024-02-13 17:18:57 +0000
commita9839cc43f831689214e3a72b582cdd5d85a4a99 (patch)
tree80861ec5a8a5127d8d33d8c6371bb6ccfc44a846
parent317483707cbea5d2ed1c717cb6756565f9f55972 (diff)
Document usage with FFmpeg (#31)
-rw-r--r--README.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8eb0eae..30e061d 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,23 @@ There's nothing stopping us from using a different rate than the actual device r
$ parec --channels=1 --device="${PASOURCE}" --raw | specgram -l -r 1e-8
```
+#### Usage with FFmpeg
+
+In order to generate a spectrogram for an encoded audio file, it is neccesarily to decode it first. This can be done with FFmpeg, using any of the [raw audio formats available](https://trac.ffmpeg.org/wiki/audio%20types#SampleFormats).
+
+For example, to generate the spectrogram for an MP3 file:
+
+```bash
+$ ffmpeg -i input.mp3 -f s16le - | specgram output.png
+```
+
+Or, in order to use 32-bit data:
+
+```bash
+$ ffmpeg -i input.mp3 -f s32le - | specgram -d s32 output.png
+```
+Note that you will have to manually stop specgram with a SIGINT once the ffmpeg stream is finished.
+
### FFT options
The FFT window width can be specified with ```-f, --fft_width``` and the stride, that is the distance between the beginning of two subsequent FFT windows, can be specified with ```-g, --fft_stride```: