Skip to main content

SSTV generator in pure Python

PySSTV generates SSTV modulated WAV files from any image that PIL can open (PNG, JPEG, GIF, and many others). These WAV files then can be played by any audio player connected to a shortwave radio for example.

My main motivation was to understand the internals of SSTV in practice, so performance is far from optimal. I tried keeping the code readable, and only performed such optimizations that wouldn't have complicated the codebase.

Command line usage

$ python -m pysstv -h
usage: __main__.py [-h]
              [--mode {MartinM1,MartinM2,ScottieS1,ScottieS2,ScottieDX,Robot36,PasokonP3,PasokonP5,PasokonP7,PD90,PD120,PD160,PD180,PD240,PD290,WraaseSC2120,WraaseSC2180,Robot8BW,Robot24BW}]
              [--rate RATE] [--bits BITS] [--vox] [--fskid FSKID]
              [--chan CHAN] [--resize] [--keep-aspect-ratio]
              [--keep-aspect] [--resample {nearest,bicubic,lanczos}]
              image.png output.wav

Converts an image to an SSTV modulated WAV file.

positional arguments:
  image.png             input image file name
  output.wav            output WAV file name

options:
  -h, --help            show this help message and exit
  --mode {MartinM1,MartinM2,ScottieS1,ScottieS2,ScottieDX,Robot36,PasokonP3,PasokonP5,PasokonP7,PD90,PD120,PD160,PD180,PD240,PD290,WraaseSC2120,WraaseSC2180,Robot8BW,Robot24BW}
                        image mode (default: Martin M1)
  --rate RATE           sampling rate (default: 48000)
  --bits BITS           bits per sample (default: 16)
  --vox                 add VOX tones at the beginning
  --fskid FSKID         add FSKID at the end
  --chan CHAN           number of channels (default: mono)
  --resize              resize the image to the correct size
  --keep-aspect-ratio   keep the original aspect ratio when resizing
                            (and cut off excess pixels)
  --keep-aspect         keep the original aspect ratio when resizing
                            (not cut off excess pixels)
  --resample {nearest,bicubic,lanczos}
                        which resampling filter to use for resizing
                            (see Pillow documentation)

Python interface

The SSTV class in the sstv module implements basic SSTV-related functionality, and the classes of other modules such as grayscale and color extend this. Most instances implement the following methods:

  • __init__ takes a PIL image, the samples per second, and the bits per sample as a parameter, but doesn't perform any hard calculations
  • gen_freq_bits generates tuples that describe a sine wave segment with frequency in Hz and duration in ms
  • gen_values generates samples between -1 and +1, performing sampling according to the samples per second value given during construction
  • gen_samples generates discrete samples, performing quantization according to the bits per sample value given during construction
  • write_wav writes the whole image to a Microsoft WAV file

The above methods all build upon those above them, for example write_wav calls gen_samples, while latter calls gen_values, so typically, only the first and the last, maybe the last two should be called directly, the others are just listed here for the sake of completeness and to make the flow easier to understand.

License

The whole project is available under MIT license.

Useful links

Dependencies

  • Python 3.5 or later
  • Python Imaging Library (Debian/Ubuntu package: python3-pil)

Release files for pySSTV 0.5.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pySSTV 0.5.9
File Size Uploaded
pysstv-0.5.9.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pySSTV 0.5.9
File Interpreter ABI Platform
pysstv-0.5.9-py3-none-any.whl Python 3 none any Details

Total release size: 37.5 kB

Release files / pysstv-0.5.9.tar.gz

Download URL pysstv-0.5.9.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2773599a5a90bb6def7e4a85ffd296176e5009055aa25d91081d4d6c111cdf87
BLAKE2b-256 checksum
How to use checksums
600dd583337f2ee0f6e9e7519b9ff628ce44ec056401b294566d9e6532cdd4df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pysstv-0.5.9-py3-none-any.whl

Download URL pysstv-0.5.9-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74b1b4e4b3b8711014618a4f222c0ec74e23e6bce5d4bab4ed99179232a2b3cb
BLAKE2b-256 checksum
How to use checksums
6e9b953ac1b0c6769dfc6728735cc97a27de35f6f77fe76694118e2843f4c464
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.5.9 This release

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5

2 release files

0.4.4

2 release files

0.4.3

1 release file

0.4.1

1 release file

0.4

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page