code: def run_ffmpeg_command(self):
          
          logger.debug("Running ffmpeg command: {}".format(self.cmd))
  
          if self.dry:
              logger.debug("Dry mode specified, not actually running command")
              return
  
          total_dur = None
  
          stderr = []
  
          p = subprocess.Popen(
              self.cmd,
              stdout=subprocess.PIPE,
              stderr=subprocess.PIPE,
              universal_newlines=False
          )
  
          # for stderr_line in iter(p.stderr):
          while True:
              line = p.stderr.readline().decode("utf8", errors='replace')
              if line == '' and p.poll() is not None:
                  break
              stderr.append(line.strip())
              self.output = "\n".join(stderr)
  
              if not total_dur and CommandRunner.DUR_REGEX.search(line):
                  total_dur = CommandRunner.DUR_REGEX.search(line).groupdict()
                  total_dur = to_ms(**total_dur)
                  continue
              if total_dur:
                  result = CommandRunner.TIME_REGEX.search(line)
                  if result:
                      elapsed_time = to_ms(**result.groupdict())
                      yield int(elapsed_time / total_dur * 100)
  
          if p.returncode != 0:
              raise RuntimeError("Error running command {}: {}".format(self.cmd, str("\n".join(stderr))))
  
          yield 100
docs: Run an ffmpeg command, trying to capture the process output and calculate
          the duration / progress.
          Yields the progress in percent.