class_docstr: WriteGear handles various powerful Video-Writer Tools that provide us the freedom to do almost anything imaginable with multimedia data.
  
  WriteGear API provides a complete, flexible, and robust wrapper around FFmpeg, a leading multimedia framework. WriteGear can process real-time frames into a lossless
  compressed video-file with any suitable specification (such as bitrate, codec, framerate, resolution, subtitles, etc.). It is powerful enough to perform complex tasks such as
  Live-Streaming (such as for Twitch) and Multiplexing Video-Audio with real-time frames in way fewer lines of code.
  
  Best of all, WriteGear grants users the complete freedom to play with any FFmpeg parameter with its exclusive Custom Commands function without relying on any
  third-party API.
  
  In addition to this, WriteGear also provides flexible access to OpenCV's VideoWriter API tools for video-frames encoding without compression.
  
  ??? tip "Modes of Operation"
  
      WriteGear primarily operates in following modes:
  
      * **Compression Mode**: In this mode, WriteGear utilizes powerful **FFmpeg** inbuilt encoders to encode lossless multimedia files.
                              This mode provides us the ability to exploit almost any parameter available within FFmpeg, effortlessly and flexibly,
                              and while doing that it robustly handles all errors/warnings quietly.
  
      * **Non-Compression Mode**: In this mode, WriteGear utilizes basic **OpenCV's inbuilt VideoWriter API** tools. This mode also supports all
                                  parameters manipulation available within VideoWriter API, but it lacks the ability to manipulate encoding parameters
                                  and other important features like video compression, audio encoding, etc.
class_docstr_tok: ["WriteGear","handles","various","powerful","Video-Writer","Tools","that","provide","us","the","freedom","to","do","almost","anything","imaginable","with","multimedia","data",".","WriteGear","API","provides","a","complete",",","flexible",",","and","robust","wrapper","around","FFmpeg",",","a","leading","multimedia","framework",".","WriteGear","can","process","real-time","frames","into","a","lossless","compressed","video-file","with","any","suitable","specification","(","such","as","bitrate",",","codec",",","framerate",",","resolution",",","subtitles",",","etc.",")",".","It","is","powerful","enough","to","perform","complex","tasks","such","as","Live-Streaming","(","such","as","for","Twitch",")","and","Multiplexing","Video-Audio","with","real-time","frames","in","way","fewer","lines","of","code",".","Best","of","all",",","WriteGear","grants","users","the","complete","freedom","to","play","with","any","FFmpeg","parameter","with","its","exclusive","Custom","Commands","function","without","relying","on","any","third-party","API",".","In","addition","to","this",",","WriteGear","also","provides","flexible","access","to","OpenCV","'s","VideoWriter","API","tools","for","video-frames","encoding","without","compression",".","?","?","?","tip","``","Modes","of","Operation","''","WriteGear","primarily","operates","in","following","modes",":","*","*","*","Compression","Mode","*","*",":","In","this","mode",",","WriteGear","utilizes","powerful","*","*","FFmpeg","*","*","inbuilt","encoders","to","encode","lossless","multimedia","files",".","This","mode","provides","us","the","ability","to","exploit","almost","any","parameter","available","within","FFmpeg",",","effortlessly","and","flexibly",",","and","while","doing","that","it","robustly","handles","all","errors\/warnings","quietly",".","*","*","*","Non-Compression","Mode","*","*",":","In","this","mode",",","WriteGear","utilizes","basic","*","*","OpenCV","'s","inbuilt","VideoWriter","API","*","*","tools",".","This","mode","also","supports","all","parameters","manipulation","available","within","VideoWriter","API",",","but","it","lacks","the","ability","to","manipulate","encoding","parameters","and","other","important","features","like","video","compression",",","audio","encoding",",","etc","."]
docstr: An Internal method that launches FFmpeg subprocess pipeline in Compression Mode
  for pipelining frames to `stdin`.
  
  Parameters:
      input_params (dict): Input FFmpeg parameters
      output_params (dict): Output FFmpeg parameters
docstr_tok: ["An","Internal","method","that","launches","FFmpeg","subprocess","pipeline","in","Compression","Mode","for","pipelining","frames","to","`","stdin","`",".","Parameters",":","input_params","(","dict",")",":","Input","FFmpeg","parameters","output_params","(","dict",")",":","Output","FFmpeg","parameters"]
code: def __start_FFProcess(self, input_params, output_params):
      """
      An Internal method that launches FFmpeg subprocess pipeline in Compression Mode
      for pipelining frames to `stdin`.
  
      Parameters:
          input_params (dict): Input FFmpeg parameters
          output_params (dict): Output FFmpeg parameters
      """
      # convert input parameters to argument list
      input_parameters = dict2Args(input_params)
  
      # handle output video encoder.
      # get list of supported video-encoders
      supported_vcodecs = get_supported_vencoders(self.__ffmpeg)
      # dynamically select default encoder
      default_vcodec = [
          vcodec
          for vcodec in ["libx264", "libx265", "libxvid", "mpeg4"]
          if vcodec in supported_vcodecs
      ][0] or "unknown"
      # extract any user-defined encoder
      if "-c:v" in output_params:
          # assign it to the pipeline
          output_params["-vcodec"] = output_params.pop(
              "-c:v", default_vcodec
          )
      if not "-vcodec" in output_params:
          # auto-assign default video-encoder (if not assigned by user).
          output_params["-vcodec"] = default_vcodec
      if (
          default_vcodec != "unknown"
          and not output_params["-vcodec"] in supported_vcodecs
      ):
          # reset to default if not supported
          logger.critical(
              "Provided FFmpeg does not support `{}` video-encoder. Switching to default supported `{}` encoder!".format(
                  output_params["-vcodec"], default_vcodec
              )
          )
          output_params["-vcodec"] = default_vcodec
  
      # assign optimizations based on selected video encoder(if any)
      if output_params["-vcodec"] in supported_vcodecs:
          if output_params["-vcodec"] in ["libx265", "libx264"]:
              if not "-crf" in output_params:
                  output_params["-crf"] = "18"
              if not "-preset" in output_params:
                  output_params["-preset"] = "fast"
          if output_params["-vcodec"] in ["libxvid", "mpeg4"]:
              if not "-qscale:v" in output_params:
                  output_params["-qscale:v"] = "3"
      else:
          # raise error otherwise
          raise RuntimeError(
              "[WriteGear:ERROR] :: Provided FFmpeg does not support any suitable/usable video-encoders for compression."
              " Kindly disable compression mode or switch to another FFmpeg binaries(if available)."
          )
  
      # convert output parameters to argument list
      output_parameters = dict2Args(output_params)
  
      # format FFmpeg command
      cmd = (
          [self.__ffmpeg, "-y"]
          + self.__ffmpeg_preheaders
          + ["-f", "rawvideo", "-vcodec", "rawvideo"]
          + input_parameters
          + ["-i", "-"]
          + output_parameters
          + [self.__out_file]
      )
      # Launch the process with FFmpeg command
      if self.__logging:
          # log command in logging mode
          logger.debug(
              "Executing FFmpeg command: `{}`".format(" ".join(cmd))
          )
          # In logging mode
          self.__process = sp.Popen(
              cmd, stdin=sp.PIPE, stdout=sp.PIPE, stderr=None
          )
      else:
          # In silent mode
          self.__process = sp.Popen(
              cmd,
              stdin=sp.PIPE,
              stdout=sp.DEVNULL,
              stderr=sp.STDOUT,
              creationflags=(  # this prevents ffmpeg creation window from opening when building exe files on Windows
                  sp.DETACHED_PROCESS
                  if self.__ffmpeg_window_disabler_patch
                  else 0
              ),
          )
  
file_path: vidgear/vidgear/gears/writegear.py
imports: import os
  import cv2
  import time
  import platform
  import pathlib
  import logging
  import subprocess
  from .helper import capPropId, dict2Args, is_valid_url, logger_handler, check_WriteAccess, get_valid_ffmpeg_path, get_supported_pixfmts, get_supported_vencoders, check_gstreamer_support, logcurr_vidgear_ver
label_desc: Use image node_id 4 for calling the WriteGear obj's underlying member method code with example usage: obj.__start_FFProcess(input_params, output_params) without return types