Skip to content

WriteGear API: Compression Mode

Compression Mode
WriteGear API's Compression Mode generalized workflow

Overview

When compression_mode parameter is enabled (.i.e compression_mode = True), WriteGear API provides a complete, flexible & robust wrapper around FFmpeg to encode lossless & compressed multimedia files.

This mode can process real-time video frames into a lossless compressed format with any suitable setting video/audio properties such as bitrate, codec, framerate, resolution, subtitles, and much more in just a few easy lines of code. It can also perform complex tasks such as Live-Streaming (such as for Twitch), multiplexing video with audio in real-time (see this usage example) while handling all errors robustly.

 

Important Information

  • WriteGear MUST requires FFmpeg executables for its Compression capabilities. Follow these dedicated Installation Instructions ➶ for its installation.

  • In case WriteGear API fails to detect valid FFmpeg executables on your system (even if Compression Mode is enabled), it automatically fallbacks to Non-Compression Mode.

  • It is advised to enable logging(logging = True) to see the FFmpeg command that is being executed in WriteGear's pipeline. This helps you debug any issues/errors easily and make suitable adjustments accordingly.

You can speed up the execution time by disabling logging (.i.e logging = False) for production use, and by tweaking FFmpeg parameters in output_params values. Look into FFmpeg docs ➶ for such hacks.

 

Custom FFmpeg Commands in WriteGear API

WriteGear API now provides the execute_ffmpeg_cmd Function in Compression Mode, that enables the user to pass any custom CLI commands as an input to its internal FFmpeg Pipeline by formating it as a list.

This function opens endless possibilities of exploiting any FFmpeg supported parameter within WriteGear, without relying on a third-party library/API to do the same, and while doing that it robustly handles all errors/warnings quietly.

A complete guide on execute_ffmpeg_cmd Function can be found here ➶

 

Usage Examples

After going through WriteGear Usage Examples, Checkout more bonus examples here ➶

Parameters