Compress Audio to Shorten SHN Format Using FFmpeg
This article explains how to compress audio files into the Lossless
Audio Shorten (SHN) format using FFmpeg. Since FFmpeg natively supports
decoding SHN files but lacks a native SHN encoder, this guide
demonstrates how to pipe FFmpeg’s output into the command-line
shorten tool to successfully compress your audio.
Why You Need an External Tool
While FFmpeg is excellent at reading and converting .shn
files to modern formats like FLAC or WAV, it does not contain an
internal encoder to write SHN files. To compress audio to SHN, you must
use FFmpeg to decode your source file to raw WAV data and pipe that
stream into the official shorten command-line utility.
Prerequisites
Before starting, ensure you have both tools installed on your system:
1. FFmpeg: Available on most package managers or the
official website. 2. Shorten: The original command-line
compiler for SHN files (often installable via packages like
shorten on Linux/macOS).
The Compression Command
To compress any audio file supported by FFmpeg into a Shorten (.shn) file, run the following command in your terminal:
ffmpeg -i input.wav -f wav - | shorten - output.shnHow the Command Works
ffmpeg -i input.wav: Specifies the source audio file. FFmpeg can read almost any format (MP3, FLAC, M4A, etc.) as the input.-f wav: Forces the output format to be WAV.-(after -f wav): Directs FFmpeg to send the output to the standard output stream (stdout) instead of saving it to a file.|(pipe): Takes the stdout of FFmpeg and redirects it as the input for the next command.shorten: Calls the Shorten compression tool.-(after shorten): Tells theshortentool to read the incoming WAV stream from standard input (stdin).output.shn: The final compressed output file.
Decompressing SHN Files
If you ever need to decompress an SHN file back into a standard format, FFmpeg can handle this natively without any external tools. Use the following simple command:
ffmpeg -i input.shn output.flacThis command directly converts the legacy SHN file into a modern, widely-supported lossless FLAC file.