Add files via upload

initial bingus
This commit is contained in:
Lexi Deville 2023-10-26 01:03:38 -05:00 committed by GitHub
parent 89ed538bd2
commit 004672cded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 161 additions and 0 deletions

48
AudioConverter.desktop Normal file
View file

@ -0,0 +1,48 @@
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=audio/*;
Actions=ConvertToMP3;ConvertToAAC;ConvertToOGG;ConvertToWMA;ConvertToFLAC;ConvertToALAC;ConvertToWAV;ConvertToAIFF;
X-KDE-Submenu=Convert Audio
Icon=audio-x-generic
X-KDE-StartupNotify=false
[Desktop Action ConvertToMP3]
Name=Convert to MP3
Exec=~/Scripts/ffmpegconvert.sh %U mp3
Icon=audio-mpeg
[Desktop Action ConvertToAAC]
Name=Convert to AAC
Exec=~/Scripts/ffmpegconvert.sh %U aac
Icon=audio-aac
[Desktop Action ConvertToOGG]
Name=Convert to OGG
Exec=~/Scripts/ffmpegconvert.sh %U ogg
Icon=audio-x-vorbis+ogg
[Desktop Action ConvertToWMA]
Name=Convert to WMA
Exec=~/Scripts/ffmpegconvert.sh %U wma
Icon=audio-x-ms-wma
[Desktop Action ConvertToFLAC]
Name=Convert to FLAC
Exec=~/Scripts/ffmpegconvert.sh %U flac
Icon=audio-x-flac
[Desktop Action ConvertToALAC]
Name=Convert to ALAC
Exec=~/Scripts/ffmpegconvert.sh %U alac
Icon=audio-alac
[Desktop Action ConvertToWAV]
Name=Convert to WAV
Exec=~/Scripts/ffmpegconvert.sh %U wav
Icon=audio-x-wav
[Desktop Action ConvertToAIFF]
Name=Convert to AIFF
Exec=~/Scripts/ffmpegconvert.sh %U aiff
Icon=audio-x-aiff

58
MediaConverter.desktop Normal file
View file

@ -0,0 +1,58 @@
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=video/*;
Actions=ConvertToMP4;ConvertToAVI;ConvertToMOV;ConvertToMKV;ConvertToWMV;ConvertToFLV;ConvertToMPG;ConvertToMP3;ConvertToOGG;ConvertToWebM;
X-KDE-Submenu=Convert Video
Icon=video-x-generic
X-KDE-StartupNotify=false
[Desktop Action ConvertToMP4]
Name=Convert to MP4
Exec=~/Scripts/ffmpegconvert.sh %U mp4
Icon=video-mp4
[Desktop Action ConvertToAVI]
Name=Convert to AVI
Exec=~/Scripts/ffmpegconvert.sh %U avi
Icon=video-x-msvideo
[Desktop Action ConvertToMOV]
Name=Convert to MOV
Exec=~/Scripts/ffmpegconvert.sh %U mov
Icon=video-quicktime
[Desktop Action ConvertToMKV]
Name=Convert to MKV
Exec=~/Scripts/ffmpegconvert.sh %U mkv
Icon=video-x-matroska
[Desktop Action ConvertToWMV]
Name=Convert to WMV
Exec=~/Scripts/ffmpegconvert.sh %U wmv
Icon=video-x-ms-wmv
[Desktop Action ConvertToFLV]
Name=Convert to FLV
Exec=~/Scripts/ffmpegconvert.sh %U flv
Icon=video-x-flv
[Desktop Action ConvertToMPG]
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
Icon=video-x-theora+ogg
[Desktop Action ConvertToWebM]
Name=Convert to WebM
Exec=~/Scripts/ffmpegconvert.sh %U webm
Icon=video-webm
[Desktop Action ConvertToMP3]
Name=Convert to MP3
Exec=~/Scripts/ffmpegconvert.sh %U mp3
Icon=audio-mp3

55
ffmpegconvert.sh Normal file
View file

@ -0,0 +1,55 @@
#!/bin/bash
input_file="$1"
output_extension="$2"
filename=$(basename -- "$input_file")
filename_noext="${filename%.*}"
output_file="${filename_noext}.${output_extension}"
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."
exit 1
fi
# init var for ffmpeg stderrrrr
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
exit 1
fi
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
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)
else
error_output=$(ffmpeg -i "$input_file" "$output_file" 2>&1)
fi
# check exit statuses
if [ $? -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."
else
kdialog --error "An unknown error occurred:\n$error_output"
fi
exit 1
fi