mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-31 03:09:56 -06:00
adding convert node
This commit is contained in:
Binary file not shown.
@@ -2,10 +2,31 @@
|
||||
"Flow":{
|
||||
"Parts": {
|
||||
"MusicFile": {
|
||||
"Description": "An input music file that has had its MusicInformation read and can be processed"
|
||||
"Description": "An input music file that has had its MusicInformation read and can be processed",
|
||||
"Outputs": {
|
||||
"1": "Music file from library"
|
||||
}
|
||||
},
|
||||
"ConvertAudio": {
|
||||
"Description": "Convert a music file to the specified audio codec",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file",
|
||||
"2": "Audio already in codec, no conversion done"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new file, the higher the bitrate the better the quality but larger the file.",
|
||||
"Codec": "Codec",
|
||||
"Codec-Help": "The audio codec to convert the file into.",
|
||||
"SkipIfCodecMatches": "Skip If Codec Matches",
|
||||
"SkipIfCodecMatches-Help": "If the existing audio codec matches, this file will not be processed regardless of the bitrate. Otherwise if off, the bitrate must be less than or equal to for it to skip."
|
||||
}
|
||||
},
|
||||
"ConvertToAAC": {
|
||||
"Description": "Convert a music file to AAC",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new AAC file, the higher the bitrate the better the quality but larger the file. 192 Kbps is the recommended rate."
|
||||
@@ -13,6 +34,9 @@
|
||||
},
|
||||
"ConvertToFLAC": {
|
||||
"Description": "Convert a music file to FLAC",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new FLAC file, the higher the bitrate the better the quality but larger the file. 128 Kbps is the recommended rate."
|
||||
@@ -20,6 +44,9 @@
|
||||
},
|
||||
"ConvertToMP3": {
|
||||
"Description": "Convert a music file to MP3",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new MP3 file, the higher the bitrate the better the quality but larger the file. 192 Kbps is the recommended rate."
|
||||
@@ -27,6 +54,9 @@
|
||||
},
|
||||
"ConvertToOGG": {
|
||||
"Description": "Convert a music file to OGG",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new OGG file, the higher the bitrate the better the quality but larger the file. 128 Kbps is the recommended rate."
|
||||
@@ -34,6 +64,9 @@
|
||||
},
|
||||
"ConvertToWAV": {
|
||||
"Description": "Convert a music file to WAV",
|
||||
"Outputs": {
|
||||
"1": "Audio converted and saved to temporary file"
|
||||
},
|
||||
"Fields": {
|
||||
"Bitrate": "Bitrate",
|
||||
"Bitrate-Help": "The bitrate for the new WAV file, the higher the bitrate the better the quality but larger the file. 128 Kbps is the recommended rate."
|
||||
|
||||
@@ -90,6 +90,64 @@ namespace FileFlows.MusicNodes
|
||||
// }
|
||||
//}
|
||||
|
||||
public class ConvertAudio : ConvertNode
|
||||
{
|
||||
protected override string Extension => Codec;
|
||||
|
||||
public static List<ListOption> BitrateOptions => ConvertNode.BitrateOptions;
|
||||
|
||||
[Select(nameof(CodecOptions), 0)]
|
||||
public string Codec { get; set; }
|
||||
|
||||
[Boolean(3)]
|
||||
public bool SkipIfCodecMatches { get; set; }
|
||||
|
||||
public override int Outputs => 2;
|
||||
|
||||
private static List<ListOption> _CodecOptions;
|
||||
public static List<ListOption> CodecOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodecOptions == null)
|
||||
{
|
||||
_CodecOptions = new List<ListOption>
|
||||
{
|
||||
new ListOption { Label = "AAC", Value = "aac"},
|
||||
new ListOption { Label = "MP3", Value = "MP3"},
|
||||
new ListOption { Label = "OGG", Value = "ogg"},
|
||||
new ListOption { Label = "WAV", Value = "wav"},
|
||||
};
|
||||
}
|
||||
return _CodecOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
MusicInfo musicInfo = GetMusicInfo(args);
|
||||
if (musicInfo == null)
|
||||
return -1;
|
||||
|
||||
if(musicInfo.Codec?.ToLower() == Codec?.ToLower())
|
||||
{
|
||||
if (SkipIfCodecMatches)
|
||||
{
|
||||
args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.BitRate}', and set to skip if codec matches");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(musicInfo.BitRate <= Bitrate)
|
||||
{
|
||||
args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.BitRate}'");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return base.Execute(args);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ConvertNode:MusicNode
|
||||
{
|
||||
protected abstract string Extension { get; }
|
||||
|
||||
Reference in New Issue
Block a user