]> Sergey Matveev's repositories - nnn.git/commitdiff
Add an mp3 ringtone generator
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 21 Jun 2019 17:06:34 +0000 (22:36 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 21 Jun 2019 17:06:34 +0000 (22:36 +0530)
plugins/README.md
plugins/ndiff
plugins/ringtone [new file with mode: 0755]
plugins/splitjoin

index 0b9a742825fa52521cb5db24fec5722b2f269334..ecb8519ef6f804db2d8c41b44170b9b709db6c0f 100644 (file)
@@ -18,6 +18,7 @@
 | pdfview | sh | pdftotext/mupdf-tools | View PDF file in `$PAGER` |
 | picker | sh | nnn | Pick files and pipe the newline-separated list to another utility |
 | pywal | sh | pywal | Set selected image as wallpaper, change terminal color scheme |
+| ringtone | sh | date, ffmpeg | Create a variable bitrate mp3 ringtone from file |
 | splitjoin | sh | split, cat | Split file or join selection |
 | sxiv | sh | sxiv | Browse images in a dir in sxiv, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts))|
 | transfer | sh | curl | Upload file to transfer.sh |
index 9590cf497e5b93297a5689a66529e9c5003978ae..3e9d8a462424d05a71cc910c9b85271430dc35ec 100755 (executable)
@@ -6,7 +6,7 @@
 #       press 'Enter' to ignore and proceed.
 #
 # Shell: POSIX compliant
-# Author: Arun Prakash Jana
+# Authors: Arun Prakash Jana, ath3
 
 selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
 
diff --git a/plugins/ringtone b/plugins/ringtone
new file mode 100755 (executable)
index 0000000..3b16edd
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env sh
+
+# Description: Create an mp3 ringtone out of an audio file in any format
+#              Needs user to provide start and end where to cut the file
+#              Input file audio.ext results in audio_ringtone.mp3
+# Requires: date, ffmpeg
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+    echo -n "start (hh:mm:ss): "
+    read start
+    st=`date -d "$start" +%s`
+
+    echo -n "end (hh:mm:ss): "
+    read end
+    et=`date -d "$end" +%s`
+
+    if [ $st -ge $et ]; then
+        echo "error: start >= end"
+        exit 1
+    fi
+
+    interval=$(( $et - $st ))
+
+    outfile=`basename "$1"`
+    outfile="${outfile%.*}"_ringtone.mp3
+
+    ffmpeg -i "$1" -ss "$start" -t "$interval" -vn -sn -acodec libmp3lame -q:a 2 "$outfile"
+fi
index f79d92e3296ba9e81fe979f3a36c83771e8f6242..60a5408264263f622b2bc821e2379a50a38e21c9 100755 (executable)
@@ -6,7 +6,7 @@
 #       Adds '.out suffix to the first file to be joined and saves as output file for join
 #
 # Shell: POSIX compliant
-# Author: Arun Prakash Jana
+# Authors: Arun Prakash Jana, ath3
 
 selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
 resp=s