summaryrefslogtreecommitdiff
path: root/to-mp3
diff options
context:
space:
mode:
Diffstat (limited to 'to-mp3')
-rw-r--r--to-mp3/description1
-rwxr-xr-xto-mp3/m4a-to-mp3.sh23
2 files changed, 24 insertions, 0 deletions
diff --git a/to-mp3/description b/to-mp3/description
new file mode 100644
index 0000000..219ea00
--- /dev/null
+++ b/to-mp3/description
@@ -0,0 +1 @@
+Tools for converting files to mp3 format \ No newline at end of file
diff --git a/to-mp3/m4a-to-mp3.sh b/to-mp3/m4a-to-mp3.sh
new file mode 100755
index 0000000..ae2e412
--- /dev/null
+++ b/to-mp3/m4a-to-mp3.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# reference: https://superuser.com/questions/704493/ffmpeg-convert-m4a-files-to-mp3-without-significant-loss-of-information-quali/704535#704535
+
+logfile="/mnt/bgstack15/log/m4a-to-mp3.$( date -u "+%FT%H%M%SZ" ).log"
+
+func() {
+for word in "$@" ;
+do
+ echo "Entering item ${word}";
+ outdir="${word}/mp3" ; mkdir "${outdir}" || exit 1 ;
+ find "${word}" -type f \( -regex '.*M4A' -o -regex '.*m4a' \) | while IFS='\0' read infile ;
+ do
+ test -f "${infile}" && echo "Found file: \"${infile}\"" || echo "INVALID! ${infile}"
+ outfile="$( echo "${infile}" | sed -r -e "s/\.m4a/\.mp3/i" )"
+ echo ffmpeg -i \"${infile}\" -codec:v copy -codec:a libmp3lame -q:a 2 \"${outfile}\"
+ yes | ffmpeg -i "${infile}" -codec:v copy -codec:a libmp3lame -q:a 2 -y "${outfile}" ; test -n "${outdir}" && /bin/mv -f "${outfile}" "${outdir}/" ;
+ sleep 2 ;
+ done
+done
+}
+
+
+time func "$@" | tee -a "${logfile}"
bgstack15