code: def encode(self, source_path, target_path, params):  # NOQA: C901
          
          total_time = self.get_media_info(source_path)['duration']
  
          cmds = [self.ffmpeg_path, '-i', source_path]
          cmds.extend(self.params)
          cmds.extend(params)
          cmds.extend([target_path])
  
          process = self._spawn(cmds)
  
          buf = output = ''
          # update progress
          while True:
              # any more data?
              out = process.stderr.read(10)
              if not out:
                  break
  
              out = out.decode(console_encoding)
              output += out
              buf += out
  
              try:
                  line, buf = buf.split('\r', 1)
              except ValueError:
                  continue
  
              try:
                  time_str = RE_TIMECODE.findall(line)[0]
              except IndexError:
                  continue
  
              # convert progress to percent
              time = 0
              for part in time_str.split(':'):
                  time = 60 * time + float(part)
  
              percent = time / total_time
              logger.debug('yield {}%'.format(percent))
              yield percent
  
          if os.path.getsize(target_path) == 0:
              raise exceptions.FFmpegError("File size of generated file is 0")
  
          # wait for process to exit
          self._check_returncode(process)
  
          logger.debug(output)
          if not output:
              raise exceptions.FFmpegError("No output from FFmpeg.")
  
          yield 100
docs: Encodes a video to a specified file. All encoder specific options
          are passed in using `params`.