package ONO::Lib::Audio::ToolBox;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2000-2025 Jos KIRPS [ www.kirps.com | jos_AT_kirps_DOT_com ]
# and The Joopita Project [ www.joopita.org | contact_AT_joopita_DOT_com ]
#
# This file, as well as other parts of the ONO Software Project or related
# elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################
use strict;
use ONO::IO;
use ONO::Lib::Video::ToolBox;
use ONO::Lib::Code::RandomID;
use ONO::Core;
###############################################################################
# extract a cover images
###############################################################################
sub convertticket {
#: Generate a conversion request ticket.
my $ID = ONO::Lib::Code::RandomID->make();
ONO::IO->mkpath("var/tmp/cronsync/audio2mp3queue");
ONO::IO->chmod("var/tmp/cronsync/audio2mp3queue",777);
ONO::IO->store("var/tmp/cronsync/audio2mp3queue/$ID.txt",$_[1]);
ONO::IO->chmod("var/tmp/cronsync/audio2mp3queue/$ID.txt",777);
}
sub convert {
#: Convert a file.
my (
$self,
$src,
$timestamp,
$ext,
$switches,
) = @_;
ONO::Lib::Video::ToolBox->convert($src,$timestamp,$ext,"a$switches");
}
###############################################################################
# extract a cover images
###############################################################################
sub extract_cover_image {
my (
$self,
$file,
) = @_;
#: Extract a cover image from an audio file.
#: This will only work for non-protected files.
if ($file =~ m~\.(mp3|m4a|wav|flac|ogg)$~ && $file !~ /'/ && $file !~ /\.pl/) {
my ($vpath,$ffmpeg) = (ONO::IO->path,ONO::Lib::Video::ToolBox->detect_ffmpeg);
if ($ffmpeg) {
my $image = ONO::IO->path2dir($file)."/cover.jpg";
if (!ONO::IO->exists($image)) {
`$ffmpeg -i '$vpath$file' '$vpath$image'`;
}
}
}
}
###############################################################################
# end of script
###############################################################################
1;
__END__