Skip to main content

j-gif

Screen recording to GIF for Python, implemented in Rust.

Frames are captured through DXGI Desktop Duplication (via hdrcapture, so HDR highlights are tone-mapped instead of clipped) with Win32 GDI (BitBlt) as the fallback, compressed to JPEG and kept in a native frame store, then encoded to GIF -- all on native threads, so the GIL is never held during recording or export.

A process can hold only one DXGI duplication per monitor. RecordSession opens its own on the recording thread, so release any other session first, or pass prefer_dxgi=False to record with GDI only.

Opening the DXGI session takes around 100 ms. To start recording without that delay, prepare the session while the recording UI is up and begin it later:

session = gifrecorder.RecordSession.prepare()        # builds the DXGI session now
session.begin(store, left, top, width, height, fps)  # first frame arrives immediately
  • FrameStore -- accepts BGRA/RGB frames, stores them JPEG-compressed, exports GIF
  • FrameDecoder -- background decoding for playback over a bounded channel
  • RecordSession -- recording state machine (recording / paused / stopped)

The distribution is j-gif; the module imports as gifrecorder.

import gifrecorder

store = gifrecorder.FrameStore(width, height, fps, jpeg_quality=90)
store.push_bgra(bgra_bytes, elapsed_ms)      # once per captured frame
store.export_gif("out.gif", repeat=0)

Playback can start directly at a frame without decoding earlier JPEGs:

decoder = store.start_decoder(display_w=640, display_h=360, start_frame=100)
try:
    frame = decoder.next_frame()  # (RGB bytes, original elapsed_ms), or None
finally:
    decoder.stop()

start_frame defaults to zero. An index at or beyond the end produces an empty decoder. total_frames counts frames from the chosen start to the end, and fetched_count starts at zero. Timestamps remain relative to the original recording. This parameter is available in j-gif 0.3.1 and later.

Windows x86_64 or ARM64, CPython 3.11+ (abi3). Part of jietuba. MIT licensed.

Metadata

Release files for j-gif 0.4.0

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

Built distributions (wheels)

Table of built distributions (wheels) for j-gif 0.4.0
File Interpreter ABI Platform Actions
j_gif-0.4.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for j_gif-0.4.0-cp311-abi3-win_arm64.whl
j_gif-0.4.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for j_gif-0.4.0-cp311-abi3-win_amd64.whl

Total release size: 990.4 kB

Release files / j_gif-0.4.0-cp311-abi3-win_arm64.whl

Download URL j_gif-0.4.0-cp311-abi3-win_arm64.whl
Size 459.3 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
82fbe32379e989e895804c86571a0775a7e0223b1a19e12fc8a992cd209215ca
BLAKE2b-256 checksum
How to use checksums
fbbfb3e8f2878c921f92c02b4db5c4a9783b1e187332cc6c088cb8df1d995ac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / j_gif-0.4.0-cp311-abi3-win_amd64.whl

Download URL j_gif-0.4.0-cp311-abi3-win_amd64.whl
Size 531.1 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
33e617ee7a68fe1b8462facfea21778138895fc0806112b40ba7bfcb9beade10
BLAKE2b-256 checksum
How to use checksums
4491b5f93dae3dc363043fa88a50030d15f0fcf461e6e16504b18ad3417ebb84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for j-gif 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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