summaryrefslogtreecommitdiff
path: root/to-mp3
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2018-06-16 15:42:30 -0400
committerB Stack <bgstack15@gmail.com>2018-06-16 15:42:30 -0400
commitdbf8fc4edb36f96602b9e1117dd561320b80fd44 (patch)
tree971c0179a38a20e6cf5dde999d11901622c29ab8 /to-mp3
parentadd raw notes about project migration (diff)
downloadformer-gists-dbf8fc4edb36f96602b9e1117dd561320b80fd44.tar.gz
former-gists-dbf8fc4edb36f96602b9e1117dd561320b80fd44.tar.bz2
former-gists-dbf8fc4edb36f96602b9e1117dd561320b80fd44.zip
add to-mp3 set with m4a-to-mp3
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