-
Notifications
You must be signed in to change notification settings - Fork 0
/
concat
executable file
·77 lines (61 loc) · 2.9 KB
/
concat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# nb: the swp file that editscript relies on is provided by nano
editscript(){
local scriptpath script path swp; scriptpath=$(realpath "$0" 2>/dev/null); script="${scriptpath##*/}"; path="${scriptpath%/*}"; swp="$path/.$script.swp"
[[ ! -e "$swp" ]] && printf "\n\n%s\n\n" "$swp" && (/usr/bin/nano "$scriptpath") && exit
printf "\n%s is already being edited.\n%s exists; try fg or look in another window.\n" "$scriptpath" "$swp"; exit ;}
pause(){ read -rp "$*" ; }
[[ "$1" == @(edit|e|nano|-e|-E) ]] && editscript
ext="opus"
#ext="m4b"
#ext="flac"
#ext="mp3"
#ext="${1##*.}"
scriptname="$(realpath $0)"
shopt -s extglob
if [[ "$1" = --ext=@(m4b|m4a|mp3) ]]; then
ext="$1"
shift
ext="${ext#*=}"
pause "new extension: $ext"
fi
title="${1%.*}"
#for i in {000..104}; do
#for f in *$i.ts; do printf %s\n file '%s\n' "$PWD"/"$f";done;
#ffmpeg -f concat -safe 0 -i <(for f in ./*.$1; do echo "file '$PWD/$f'"; done) -acodec libopus -b:a 17k "$2"
#ffmpeg -f concat -safe 0 -i <(for f in ./*.$1; do echo "file '$PWD/$f'"; done) -acodec libopus -b:a 24k "$2"
#ffmpeg -hide_banner -stats -f concat -safe 0 -i <(for f in *.mp3; do echo "file '$PWD/$f'"; done) -acodec copy "/dev/shm/cache/1.mp3"
#done
#for i in {00..18}; do cd $i;
#for d in */; do
#cd "$d"
escapepath(){
for f in ./*."$ext"*; do
if [[ "$PWD/$f" == *\'* ]]; then
ff="$f"; dir="$PWD"
[[ "$f" == *\'* ]] && ff="${f//\'/\'\\\'\'}" || ff="$f"
[[ "$PWD" = *\'* ]] && dir="${PWD//\'/\'\\\'\'}"
echo "file '$dir/$ff'" #>> "$tmp/opusfiles"
else
echo "file '$PWD/$f'" #>> "$tmp/opusfiles"
fi
done
}
#if [[ "$ext" == "flac" ]]; then
#ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(for f in ./*."$ext"*; do echo "file '$PWD/$f'"; done) "$title.$ext"
#elif [[ "$2" == "-y" ]]; then
#ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -y -i <(for f in ./*."$ext"*; do echo "file '$PWD/$f'"; done) -acodec copy "$title.$ext"
#else
#ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(for f in ./*."$ext"*; do echo "file '$PWD/$f'"; done) -acodec copy "$title.$ext"
#fi
[[ "$title" =~ \."$ext"$ ]] && title="${title%.$ext}"
if [[ "$ext" == "flac" ]]; then
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(escapepath) "$title.$ext"
elif [[ "$2" == "-y" ]]; then
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -y -i <(escapepath) -acodec copy "$title.$ext"
else
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(escapepath) -acodec copy "$title.$ext"
fi
#cd -
#done
#for i in {01..11} ; do for f in "$i.mp3"; do printf "file '%s\n'*Rabbit\ Remembered\ *$i*"; ffmpeg -n -f concat -safe 0 -i <(for f in *Remembered\ *$i*.mp3; do printf "file '%s$PWD/$f'\\n"; done) -acodec libopus -b:a 17k "Rabbit Remembered -- Chapter 0$i.opus"; done