#!/usr/bin/env perl
# Hulot converter: audio/*→audio/mpeg
# FIXME: generalise to arbitrary audio types, using output of pacpl --formats
# © Reuben Thomas 2023

use strict;
use warnings;

use Perl6::Slurp;

sub run {
  my @cmd = @_;
  open(READER, "-|", @cmd) or die "command $cmd[0] failed (open)";
  my $output = scalar(slurp '<:raw', \*READER);
  close(READER) or die "command $cmd[0] failed (close)";
  return $output;
}

my ($file) = $ARGV[0];
print run("ffmpeg", "-loglevel", "quiet", "-i", $file, "-f", "mp3", "-");
