aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mp3conv
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-23 13:01:15 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-23 13:09:24 +0530
commite73ec218a9c27b34a017c676d8ee85904ff31e2f (patch)
tree208f8383af95f096821b19eb5b091e86eff68bfd /plugins/mp3conv
parent5f419dc60312c1bb789ad865ff1cf61c21de5c2b (diff)
downloadnnn-e73ec218a9c27b34a017c676d8ee85904ff31e2f.tar.gz
Plugin mp3conv to extract audio from media as mp3
Diffstat (limited to 'plugins/mp3conv')
-rwxr-xr-xplugins/mp3conv34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/mp3conv b/plugins/mp3conv
new file mode 100755
index 0000000..b60b891
--- /dev/null
+++ b/plugins/mp3conv
@@ -0,0 +1,34 @@
+#!/usr/bin/env sh
+
+# Description: Extract audio from multimedia files and convert to mp3
+#
+# Dependency: ffmpeg compiled with libmp3lame audio codec support
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+outdir=_mp3files
+
+if ! [ -e "${outdir}" ]; then
+ mkdir "${outdir}"
+fi
+
+handle_multimedia() {
+ mime="${1}"
+ file="${2}"
+
+ case "${mime}" in
+ audio/* | video/*)
+ ffmpeg -i "${file}" -vn -codec:a libmp3lame -q:a 2 "${outdir}"/"${file%.*}.mp3"
+ ;;
+ *)
+ ;;
+ esac
+}
+
+for f in *; do
+ if [ -f "${f}" ]; then
+ mimestr="$( file --dereference --brief --mime-type -- "${f}" )"
+ handle_multimedia "${mimestr}" "${f}"
+ fi
+done