-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcat
More file actions
executable file
·49 lines (39 loc) · 1.33 KB
/
concat
File metadata and controls
executable file
·49 lines (39 loc) · 1.33 KB
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
#!/bin/bash
# nb: the swp file that editscript relies on is provided by nano
. /usr/local/bin/editscript
ext="opus"
ext="m4b"
#ext="m4a"
#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%.*}"
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
}
[[ "$title" =~ \."$ext"$ ]] && title="${title%.$ext}"
## Process substitution (<(escapepath)) creates a named pipe like /dev/fd/63, which ffmpeg treats as a normal input — no file: needed or allowed there.
if [[ "$ext" == "flac" ]]; then
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(escapepath) file:"$title.$ext"
elif [[ "$2" == "-y" ]]; then
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -y -i <(escapepath) -acodec copy file:"$title.$ext"
else
ffmpeg -nostdin -hide_banner -stats -f concat -safe 0 -thread_queue_size 1024 -i <(escapepath) -acodec copy file:"$title.$ext"
fi