Skip to content

Instantly share code, notes, and snippets.

@ology
Created August 7, 2021 06:26
Show Gist options
  • Save ology/e89a040e842f39d9185a5d8f7f694e02 to your computer and use it in GitHub Desktop.
Save ology/e89a040e842f39d9185a5d8f7f694e02 to your computer and use it in GitHub Desktop.
Mojo::File->realpath returns "" ?
app->minion->add_task(reencode_audio => sub ($job, @args) {
my $track = Mojo::File->new($args[0]);
my $path = eval { $track->realpath };
$job->app->log->debug($track, 'to', $path);
(my $outfile = $path) =~ s/^(.+?)\.\w+$/$1.mp3/;
my @cmd = (qw(ffmpeg -i), qq/"$path"/, qw(-c:v copy -c:a libmp3lame -q:a 4), qq/"$outfile"/);
$job->app->log->debug("@cmd");
# if(system(@cmd) == 0) {
# $job->app->log->debug($track, 're-encoded');
# }
# else {
# $job->app->log->error($track, 'not re-encoded:', $?);
# }
});
▸ ./audio-player2 minion worker
[2021-08-06 23:24:41.50645] [1730437] [info] Worker 1730437 started
[2021-08-06 23:25:15.54066] [1730437] [debug] Process 1730453 is performing job "41" with task "reencode_audio"
Use of uninitialized value $_[2] in join or string at /home/gene/perl5/perlbrew/perls/perl-5.32.1/lib/site_perl/5.32.1/Mojo/Log.pm line 76.
[2021-08-06 23:25:15.54198] [1730453] [debug] /Audio/Art/Adrian Belew/Side Three/01 Troubles.m4a to
Use of uninitialized value $outfile in substitution (s///) at ./audio-player2 line 303.
Use of uninitialized value $path in concatenation (.) or string at ./audio-player2 line 304.
Use of uninitialized value $outfile in concatenation (.) or string at ./audio-player2 line 304.
[2021-08-06 23:25:15.54239] [1730453] [debug] ffmpeg -i "" -c:v copy -c:a libmp3lame -q:a 4 ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment