convert any annoying media format into a standard media format
#!/bin/bash
# mediaconvert – auto-convert any media file with progress bar
infile="$1"
[ -z "$infile" ] && { echo "Usage: mediaconvert <file>"; exit 1; }
ext="${infile##*.}"
base="${infile%.*}"
case "$ext" in
avi|mov|mkv|webm|flv|mpg|mpeg|mp4)
outfile="${base}.mp4"
pv "$infile" | ffmpeg -y -i - -c:v libx264 -c:a aac -strict -2 "$outfile"
;;
mp3|m4a|ogg|wav|flac|aac|webm)
outfile="${base}.mp3"
pv "$infile" | ffmpeg -y -i - -acodec libmp3lame -q:a 2 "$outfile"
;;
jpg|jpeg|png|bmp|gif|tiff|webp)
outfile="${base}.jpg"
pv "$infile" | ffmpeg -y -i - -q:v 2 "$outfile"
;;
*)
echo "Unsupported file type: $ext"
exit 1
;;
esac
echo "Created: $outfile"
# mediaconvert – auto-convert any media file with progress bar
infile="$1"
[ -z "$infile" ] && { echo "Usage: mediaconvert <file>"; exit 1; }
ext="${infile##*.}"
base="${infile%.*}"
case "$ext" in
avi|mov|mkv|webm|flv|mpg|mpeg|mp4)
outfile="${base}.mp4"
pv "$infile" | ffmpeg -y -i - -c:v libx264 -c:a aac -strict -2 "$outfile"
;;
mp3|m4a|ogg|wav|flac|aac|webm)
outfile="${base}.mp3"
pv "$infile" | ffmpeg -y -i - -acodec libmp3lame -q:a 2 "$outfile"
;;
jpg|jpeg|png|bmp|gif|tiff|webp)
outfile="${base}.jpg"
pv "$infile" | ffmpeg -y -i - -q:v 2 "$outfile"
;;
*)
echo "Unsupported file type: $ext"
exit 1
;;
esac
echo "Created: $outfile"