From 2b219cb9016b6555774327bbf37b700addc45d81 Mon Sep 17 00:00:00 2001 From: Lexi Deville Date: Thu, 26 Oct 2023 01:38:39 -0500 Subject: [PATCH] alac is a special babyboy --- AudioConverter.desktop | 9 +++++++-- MediaConverter.desktop | 8 ++++---- ffmpegconvert.sh | 35 ++++++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/AudioConverter.desktop b/AudioConverter.desktop index c314469..7de08cf 100644 --- a/AudioConverter.desktop +++ b/AudioConverter.desktop @@ -2,7 +2,7 @@ Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=audio/*; -Actions=ConvertToMP3;ConvertToAAC;ConvertToOGG;ConvertToWMA;ConvertToFLAC;ConvertToALAC;ConvertToWAV;ConvertToAIFF; +Actions=ConvertToMP3;ConvertToAAC;ConvertToOGG;ConvertToWMA;ConvertToFLAC;ConvertToM4A;ConvertToALAC;ConvertToWAV;ConvertToAIFF; X-KDE-Submenu=Convert Audio Icon=audio-x-generic X-KDE-StartupNotify=false @@ -32,8 +32,13 @@ Name=Convert to FLAC Exec=~/Scripts/ffmpegconvert.sh %U flac Icon=audio-x-flac +[Desktop Action ConvertToM4A] +Name=Convert to M4A +Exec=~/Scripts/ffmpegconvert.sh %U m4a +Icon=audio-m4a + [Desktop Action ConvertToALAC] -Name=Convert to ALAC +Name=Convert to M4A (ALAC) Exec=~/Scripts/ffmpegconvert.sh %U alac Icon=audio-alac diff --git a/MediaConverter.desktop b/MediaConverter.desktop index e3f7262..c43a47a 100644 --- a/MediaConverter.desktop +++ b/MediaConverter.desktop @@ -2,7 +2,7 @@ Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=video/*; -Actions=ConvertToMP4;ConvertToAVI;ConvertToMOV;ConvertToMKV;ConvertToWMV;ConvertToFLV;ConvertToMPG;ConvertToMP3;ConvertToOGG;ConvertToWebM; +Actions=ConvertToMP4;ConvertToAVI;ConvertToMOV;ConvertToMKV;ConvertToWMV;ConvertToFLV;ConvertToMPG;ConvertToMP3;ConvertToOGV;ConvertToWebM; X-KDE-Submenu=Convert Video Icon=video-x-generic X-KDE-StartupNotify=false @@ -42,9 +42,9 @@ Name=Convert to MPG Exec=~/Scripts/ffmpegconvert.sh %U mpg Icon=video-x-mpeg -[Desktop Action ConvertToOGG] -Name=Convert to OGG -Exec=~/Scripts/ffmpegconvert.sh %U ogg +[Desktop Action ConvertToOGV] +Name=Convert to OGV +Exec=~/Scripts/ffmpegconvert.sh %U ogv Icon=video-x-theora+ogg [Desktop Action ConvertToWebM] diff --git a/ffmpegconvert.sh b/ffmpegconvert.sh index e23920b..10ed6b0 100644 --- a/ffmpegconvert.sh +++ b/ffmpegconvert.sh @@ -4,14 +4,19 @@ input_file="$1" output_extension="$2" filename=$(basename -- "$input_file") filename_noext="${filename%.*}" -output_file="${filename_noext}.${output_extension}" +if [ "$output_extension" == "alac" ]; then # alac is a special babyboy + output_file="${filename_noext}.m4a" +else + output_file="${filename_noext}.${output_extension}" +fi + lossy=("mp3" "aac" "ogg" "wma") lossless=("flac" "alac" "wav" "aiff") # dont overwrite a file if [ -e "$output_file" ]; then - kdialog --error "The target file already exists." + zenity --error --text="The target file already exists." exit 1 fi @@ -21,8 +26,7 @@ error_output="" # warn if lossy to lossless input_extension="${filename##*.}" if [[ " ${lossy[@]} " =~ " ${input_extension} " ]] && [[ " ${lossless[@]} " =~ " ${output_extension} " ]]; then - kdialog --warningyesno "WARNING: Converting from a lossy to a lossless format.\n\nQuality will NOT improve.\n\nCompression artifacts will be present.\n\nThis betrays the point of lossless formats.\n\nPRESERVATIONISTS WILL WEEP.\n\nContinue?" - if [ $? -ne 0 ]; then + if ! zenity --question --text="WARNING: Converting from a lossy to a lossless format.\n\nQuality will NOT improve.\n\nCompression artifacts will be present.\n\nThis betrays the point of lossless formats.\n\nPRESERVATIONISTS WILL WEEP.\n\nContinue?"; then exit 1 fi fi @@ -30,21 +34,34 @@ fi # warn if lossless to lossy input_extension="${filename##*.}" if [[ " ${lossless[@]} " =~ " ${input_extension} " ]] && [[ " ${lossy[@]} " =~ " ${output_extension} " ]]; then - kdialog --warningyesno "WARNING: Converting from a lossless to a lossy format.\n\nQuality will NOT be preserved.\n\nCompression artifacts will be PERMANENTLY introduced.\n\nCONVERTING BACK TO LOSSLESS WILL NOT UNDO THIS.\n\nContinue?" - if [ $? -ne 0 ]; then + if ! zenity --question --text="WARNING: Converting from a lossless to a lossy format.\n\nQuality will NOT be preserved.\n\nCompression artifacts will be PERMANENTLY introduced.\n\nCONVERTING BACK TO LOSSLESS WILL NOT UNDO THIS.\n\nContinue?"; then exit 1 fi fi # ffmpeg cmd changes based on ext +( if [[ " ${lossy[@]} " =~ " ${output_extension} " ]] || [[ " ${lossless[@]} " =~ " ${output_extension} " ]]; then - error_output=$(ffmpeg -i "$input_file" -q:a 0 -map a "$output_file" 2>&1) + if [ "$output_extension" == "alac" ]; then # alac is still a special babyboy + ffmpeg -i "$input_file" -acodec alac "$output_file" 2>&1 & + else + error_output=$(ffmpeg -i "$input_file" -q:a 0 -map a "$output_file" 2>&1) & + fi else - error_output=$(ffmpeg -i "$input_file" "$output_file" 2>&1) + error_output=$(ffmpeg -i "$input_file" -q:a 3 "$output_file" 2>&1) & +fi +) | zenity --progress --auto-close --auto-kill --text="Converting..." + +# check status +if [ $? -eq 0 ]; then + # zenity --info --text="Done" +else + rm -f "$output_file" + zenity --error --text="Conversion cancelled or failed" fi # check exit statuses -if [ $? -ne 0 ]; then +if [ $error_output -ne 0 ]; then # y u fail, ffmpeg???? if echo "$error_output" | grep -q "Invalid data found when processing input"; then kdialog --error "FFmpeg does not support source file type."