mirror of
https://github.com/moex3/flac2mp3.pl
synced 2024-11-25 04:30:41 -05:00
Embed cover arts into mp3 files from the flacs
This commit is contained in:
parent
ccc5ba6af9
commit
7f36a00b66
26
flac2mp3.pl
26
flac2mp3.pl
@ -5,6 +5,7 @@ use Getopt::Long;
|
|||||||
use File::Find;
|
use File::Find;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
use File::Temp qw/ tempfile /;
|
||||||
|
|
||||||
my $opt_no_genre;
|
my $opt_no_genre;
|
||||||
my $opt_comment;
|
my $opt_comment;
|
||||||
@ -214,6 +215,31 @@ sub iterFlac {
|
|||||||
if ($? != 0) {
|
if ($? != 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
embedImageFromFlac($flac, $dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub embedImageFromFlac {
|
||||||
|
my $flac = shift;
|
||||||
|
my $mp3 = shift;
|
||||||
|
|
||||||
|
# I can't get the automatic deletion working :c
|
||||||
|
my (undef, $fname) = tempfile();
|
||||||
|
# Export image from flac
|
||||||
|
qx(metaflac --export-picture-to='$fname' -- '$flac');
|
||||||
|
if ($? != 0) {
|
||||||
|
# Probably no image
|
||||||
|
unlink($fname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# Extract mime type too
|
||||||
|
my $pinfo = qx(metaflac --list --block-type=PICTURE -- '$flac');
|
||||||
|
$pinfo =~ m/MIME type: (.*)/;
|
||||||
|
my $mimeType = $1;
|
||||||
|
|
||||||
|
# Add image to mp3
|
||||||
|
qx(mid3v2 -p '${fname}:cover:3:$mimeType' -- '$mp3');
|
||||||
|
unlink($fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub argsToTags {
|
sub argsToTags {
|
||||||
|
Loading…
Reference in New Issue
Block a user