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.1

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.1
File Interpreter ABI Platform Actions
j_gif-0.4.1-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for j_gif-0.4.1-cp311-abi3-win_arm64.whl
j_gif-0.4.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for j_gif-0.4.1-cp311-abi3-win_amd64.whl

Total release size: 1.0 MB

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

Download URL j_gif-0.4.1-cp311-abi3-win_arm64.whl
Size 469.2 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6647e2089f25a976aa6856cbe1239f1214cb7256f2e7497512c7a25c63df3a48
BLAKE2b-256 checksum
How to use checksums
02a8ceac6775f9b4be5f11186ccf11add2bf2a44fd22826c002a6d4c71f00451
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.1-cp311-abi3-win_amd64.whl

Download URL j_gif-0.4.1-cp311-abi3-win_amd64.whl
Size 542.9 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b2e2ec7c35f90b4a140a98284cc5dfb65f33f15966c4d018581e65958bee1fb4
BLAKE2b-256 checksum
How to use checksums
9c9db3c754642bd7832fc6c136945f46001ffdb440ab6fe3584ce39ce43707e5
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.1

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