code: def ffmpeg_write_video(
      clip,
      filename,
      fps,
      codec="libx264",
      bitrate=None,
      preset="medium",
      with_mask=False,
      write_logfile=False,
      audiofile=None,
      threads=None,
      ffmpeg_params=None,
      logger="bar",
      pixel_format=None,
  ):
      """Write the clip to a videofile. See VideoClip.write_videofile for details
      on the parameters.
      """
      logger = proglog.default_bar_logger(logger)
  
      if write_logfile:
          logfile = open(filename + ".log", "w+")
      else:
          logfile = None
      logger(message="MoviePy - Writing video %s\n" % filename)
      if not pixel_format:
          pixel_format = "rgba" if with_mask else "rgb24"
      with FFMPEG_VideoWriter(
          filename,
          clip.size,
          fps,
          codec=codec,
          preset=preset,
          bitrate=bitrate,
          logfile=logfile,
          audiofile=audiofile,
          threads=threads,
          ffmpeg_params=ffmpeg_params,
          pixel_format=pixel_format,
      ) as writer:
          for t, frame in clip.iter_frames(
              logger=logger, with_times=True, fps=fps, dtype="uint8"
          ):
              if with_mask:
                  mask = 255 * clip.mask.get_frame(t)
                  if mask.dtype != "uint8":
                      mask = mask.astype("uint8")
                  frame = np.dstack([frame, mask])
  
              writer.write_frame(frame)
  
      if write_logfile:
          logfile.close()
      logger(message="MoviePy - Done !")
  
file_path: moviepy/moviepy/video/io/ffmpeg_writer.py
imports: import subprocess
  import numpy
  from proglog import proglog
  from moviepy.config import FFMPEG_BINARY
  from moviepy.tools import cross_platform_popen_params
label_desc: Use image node_id 1 for calling a global function with example usage: ffmpeg_write_video(clip, filename, fps, codec, bitrate, preset, with_mask, write_logfile, audiofile, threads, ffmpeg_params, logger, pixel_format) without return types