Put output string to ffmpeg command.
966232
def _put_output(self, output: Optional[str]) -> None:
        """"""
        if output is None:
            self._argv.extend(["-f", "null", "-"])
            return

        output_cmd = shlex.split(str(output))
        if len(output_cmd) > 1:
            self._argv.extend(output_cmd)
        else:
            self._argv.append(output)
687636
def get_output(command):
    """"""
    p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    p.stdin.close()
    p.stderr.close()
    line=p.stdout.readline().strip()
    p.wait()
    if type(line).__name__ == "bytes":
        line = str(line, encoding="utf-8")
    return line, p.returncode
471026
def get_transcoder():
	""""""

	transcoders = ['ffmpeg', 'avconv']
	transcoder_details = {}

	for transcoder in transcoders:
		command_path = shutil.which(transcoder)
		if command_path is None:
			transcoder_details[transcoder] = 'Not installed.'
			continue

		stdout = subprocess.run([command_path, '-codecs'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True).stdout
		mp3_encoding_support = ('libmp3lame' in stdout and 'disable-libmp3lame' not in stdout)
		if mp3_encoding_support:
			transcoder_details[transcoder] = "MP3 encoding support."
			break
		else:
			transcoder_details[transcoder] = "No MP3 encoding support."
	else:
		raise ValueError(
			f"ffmpeg or avconv must be in the path and support mp3 encoding."
			"\nDetails: {transcoder_details}"
		)

	return command_path
810838
def out_putfile(self, fpath):
        
        with open(fpath, 'w') as csv_file:
            output = csv.writer(csv_file)
            output.writerows(self.__raw_data)
609496
def _put_input(self, input_source: str) -> None:
        """"""
        input_cmd = shlex.split(str(input_source))
        if len(input_cmd) > 1:
            self._argv.extend(input_cmd)
        else:
            self._argv.extend(["-i", input_source])
871573
def execute_command(command):
    """"""

    command = shlex.split(command)
    try:
        process = subprocess.Popen(
            command,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
    except FileNotFoundError:
        raise RuntimeError("Command not found: {}".format(repr(command)))
    process.wait()
    # TODO: may use another codec to decode
    if process.returncode > 0:
        stderr = process.stderr.read().decode("utf-8")
        raise ValueError("Error executing command: {}".format(repr(stderr)))
    return process.stdout.read().decode("utf-8")
326250
def convert(input, output):
    '''
    
    '''
    dirname = os.path.dirname(output)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    basename = os.path.basename(output)
    basename = re.sub('.nii(.gz)?', '', basename)
    dcm2niix = commons.which('dcm2niix')
    cmd = [
        'dcm2niix',
        '-s', 'y',
        '-b', 'y',
        '-z', 'y',
        '-f', basename,
        '-o', dirname,
        input
    ]
    logger.debug(cmd)
    sp.check_output(cmd)
191712
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
47281
def update_output_dir(op_dir, time)
      File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
    end
924672
def puts(s='', newline=True, stream=STDOUT):
    """"""
    max_width_ctx = _get_max_width_context()
    if max_width_ctx:
        cols, separator = max_width_ctx[-1]
        s = max_width(s, cols, separator)

    if newline:
        s = tsplit(s, NEWLINES)
        s = map(str, s)
        indent = ''.join(INDENT_STRINGS)

        s = (str('\n' + indent)).join(s)

    _str = ''.join((
        ''.join(INDENT_STRINGS),
        str(s),
        '\n' if newline else ''
    ))
    stream(_str)
88924
def add_output_file(self, filename):
    
    if filename not in self.__output_files:
      self.__output_files.append(filename)
1014324
def write(output, opts = {})
      output_path = parse_input(output, false)

      FileUtils.copy_file(path, output_path) unless requires_output_file?

      command = build_command(output_path)
      run(command, opts)
      GraphicsMagick::Image.new(output_path)
    end
165793
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
1366436
function ffmpeg(os) {
  var stdio = os.stdio===undefined? STDIO:os.stdio;
  return new Promise((fres, frej) => cp.exec(command(os), {stdio}, (err, stdout, stderr) => {
    if(err) frej(err);
    else fres({stdout, stderr});
  }));
}
485846
def _prepare_output(partitions, verbose):
    """"""
    out = {}
    partitions_count = len(partitions)
    out['raw'] = {
        'offline_count': partitions_count,
    }

    if partitions_count == 0:
        out['message'] = 'No offline partitions.'
    else:
        out['message'] = "{count} offline partitions.".format(count=partitions_count)
        if verbose:
            lines = (
                '{}:{}'.format(topic, partition)
                for (topic, partition) in partitions
            )
            out['verbose'] = "Partitions:\n" + "\n".join(lines)
        else:
            cmdline = sys.argv[:]
            cmdline.insert(1, '-v')
            out['message'] += '\nTo see all offline partitions run: ' + ' '.join(cmdline)

    if verbose:
        out['raw']['partitions'] = [
            {'topic': topic, 'partition': partition}
            for (topic, partition) in partitions
        ]

    return out
1004920
function decompressOutput(output, br) {
  output.value = br.readVarint();
  decompressScript(output.script, br);
  return output;
}
1244408
def dump(self, fname):
        
        with open(fname, 'wb') as f:
            f.write(self.output)