-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpvival
694 lines (661 loc) · 19.3 KB
/
mpvival
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
#!/bin/bash
# MPVIVAL - run MPV adjusted at intervals of the total duration of a file.
# SPDX-License-Identifier: Unlicense
#
# This small work is dedicated to all those helping to protect endangered species.
# 2024 Looper Guará
# Time in seconds to press any key and exit the script
# half a second: 0.5
q=1
scp="$(basename "$0")"
swreq() {
type ffprobe >/dev/null 2>&1 || { echo >&2 "${scp}: WARNING: FFPROBE not found - aborting."; exit 1; }
type grep >/dev/null 2>&1 || { echo >&2 "${scp}: WARNING: GREP not found - aborting."; exit 1; }
type mpv >/dev/null 2>&1 || { echo >&2 "${scp}: WARNING: MPV not found - aborting."; exit 1; }
type file >/dev/null 2>&1 || { echo >&2 "${scp}: WARNING: FILE (command) not found - aborting."; exit 1; }
}
getdur() {
ffprobe -v quiet -show_entries format=duration:stream=duration -print_format default=noprint_wrappers=1:nokey=1 -i "$f1" | grep -oE '[0-9]+' | head -n 1
}
getiparam() {
if grep -qvE '^[0-9]+$' <<< "$dur" ; then
idur="$_length"
ivals=1
elif ((dur <= 12)) ; then
idur="$dur"
ivals=1
elif ((dur <= 60)) ; then
idur=$((dur / (1 * scal)))
ivals="$scal"
elif ((dur <= 327)) ; then
idur=$((dur / (2 * scal)))
ivals=$((dur / idur))
elif ((dur <= 654)) ; then
idur=$((dur / (3 * scal)))
ivals=$((dur / idur))
elif ((dur <= 981)) ; then
idur=$((dur / (4 * scal)))
ivals=$((dur / idur))
elif ((dur <= 1309)) ; then
idur=$((dur / (5 * scal)))
ivals=$((dur / idur))
elif ((dur <= 1636)) ; then
idur=$((dur / (6 * scal)))
ivals=$((dur / idur))
elif ((dur <= 1963)) ; then
idur=$((dur / (7 * scal)))
ivals=$((dur / idur))
elif ((dur <= 2290)) ; then
idur=$((dur / (8 * scal)))
ivals=$((dur / idur))
elif ((dur <= 2618)) ; then
idur=$((dur / (9 * scal)))
ivals=$((dur / idur))
elif ((dur <= 2945)) ; then
idur=$((dur / (10 * scal)))
ivals=$((dur / idur))
elif ((dur <= 3272)) ; then
idur=$((dur / (11 * scal)))
ivals=$((dur / idur))
elif ((dur <= 3600)) ; then
idur=$((dur / (12 * scal)))
ivals=$((dur / idur))
else
if ((scal == 1)) ; then
idur=300
elif ((scal == 2)) ; then
idur=240
elif ((scal == 3)) ; then
idur=180
elif ((scal == 4)) ; then
idur=120
elif ((scal == 5)) ; then
idur=60
fi
ivals=$((dur / idur))
fi
if ((_length > idur)) ; then
_length="$idur"
echo "${scp}: INFO: Clip duration reset: ${idur}s"
fi
}
uquit() {
echo "${scp}: INFO: Press any key to exit the script or skip the file."
if read -rst "$q" -N 1 ; then
echo "${scp}: File: $f1"
echo "${scp}: Interval: $ival / $ivals ($(((iterin - 1) * idur))-$((idur * iterin))s)"
echo "${scp}: Please confirm:"
select ans in "EXIT the script" "SKIP file" "Cancel" ; do
case "$ans" in
'EXIT the script' )
echo "${scp}: Clip Pattern playlist: ${lpatpl[*]}"
echo "${scp}: $((iterout - 1)) iterations completed - exiting..."
exit;;
'SKIP file' )
echo "${scp}: Clip Pattern playlist: ${lpatpl[*]}"
return 1;;
'Cancel' )
break;;
esac
done 2>&1
fi
echo
}
core() {
if [ -z "$dur" ] ; then
echo "${scp}: INFO: Total duration unknown - playing video from beginning."
fi
echo "${scp}: Interval: $ival / $ivals ($(((iterin - 1) * idur))-$((idur * iterin))s)"
echo "${scp}: Options:" "${@:-None}"
echo "${scp}: Loop Pattern: $lpat"
echo "${scp}: Starting mpv..."
mpv "$@" "$f1"
}
core_llt() {
if [ -v shuffle ] ; then
readarray -t iall < <(shuf "$fl1")
else
readarray -t iall < <(cat -s "$fl1")
fi
for (( ival=1 ; ival<=scal ; ival++ )) ; do
for line in "${iall[@]}" ; do
if [ -f "$line" ] ; then
f1="$line"
_length="$_lengtho"
dur="$(getdur)"
if ((_length > dur)) ; then
_length="$dur"
echo "${scp}: INFO: Clip duration reset: ${dur}s"
fi
idur="$dur"
ivals="$scal"
iterout=$((iterout + 1))
iterin=1
_start=$(shuf -i "0-$((dur - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
unset iterin
continue
fi
fi
core --start="$_start" --length="$_length" "$@"
else
if grep -q '[^[:space:]]' <<< "$line" ; then
if [ ${#line} -gt 90 ] ; then
echo >&2 "${scp}: WARNING: Not a regular file - skipping: ${line:0:45}...${line: -45}"
else
echo >&2 "${scp}: WARNING: Not a regular file - skipping: $line"
fi
fi
fi
done
unset _start
unset iterin
done
}
core_ll() {
if [ -v shuffle ] ; then
readarray -t iall < <(shuf "$fl1")
else
readarray -t iall < <(cat -s "$fl1")
fi
for line in "${iall[@]}" ; do
if [ -f "$line" ] ; then
f1="$line"
_length="$_lengtho"
dur="$(getdur)"
getiparam
for (( ival=1 ; ival<=ivals ; ival++ )) ; do
iterout=$((iterout + 1))
iterin=$((iterin + 1))
_start=$(shuf -i "$(((iterin - 1) * idur))-$((idur * iterin - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
readarray -O "$iterin" -t lpatpl <<< "$lpat"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
unset iterin
continue 2
fi
fi
core --start="$_start" --length="$_length" "$@"
done
echo "${scp}: Clip Pattern playlist: ${lpatpl[*]}"
unset lpatpl
unset _start
unset iterin
else
if grep -q '[^[:space:]]' <<< "$line" ; then
if [ ${#line} -gt 90 ] ; then
echo >&2 "${scp}: WARNING: Not a regular file - skipping: ${line:0:45}...${line: -45}"
else
echo >&2 "${scp}: WARNING: Not a regular file - skipping: $line"
fi
fi
fi
done
}
if (("$#" == 0)) ; then
echo "${scp}: Usage: ${scp} {[<mpv profile,...>] <clip duration> <interval scale> [-l|-s|-t] [path/]filename | --help | --version}"
elif [ '--version' = "$1" ] ; then
echo "mpvival 1.1"
elif [ '--help' = "$1" ] ; then
cat << '_EOF_'
MPVIVAL - run MPV adjusted at intervals of the total duration of a file
SYNOPSIS
mpvival {[<mpv profile>] <clip duration> <interval scale> [-l|-s|-t] [path/]filename |
--help | --version}
DESCRIPTION
MPVIVAL is a bash script that runs MPV with the start and length of playback set
based on intervals of the total duration.
MPV is run with the options: --start, --length.
MPV profile names are parsed and MPV is run according to: --profile.
MPV is only invoked once for each interval of the total duration of a file. The
playback start time is random and moves forward in the stream without repeating.
Intervals are calculated using a scale. The clip duration is reset to the
interval length if it is longer than the interval. Input directories are
expanded recursively. If a key is pressed within 1 second before MPV runs again,
the script may exit, continue, or skip the file after confirmation.
Status messages report clip duration, number of intervals, successful
iterations, and MPV options used.
INTERVAL SCALE
Intervals are scaled based on a range of 1 to 5, where 5 divides 1 hour into 60
one-minute intervals and 1 does not divide 1 minute. 12 seconds is the longest
undivided duration. More than 1 hour, the duration is divided into intervals of
5, 4, 3, 2 or 1 minutes for the scale of 1, 2, 3, 4 or 5 respectively.
Number of intervals per scale and longest duration between 60 and 3600 seconds:
Duration/Scale 1 2 3 4 5
60 1 2 3 4 5
327 2 4 6 8 10
654 3 6 9 12 15
981 4 8 12 16 20
1309 5 10 15 20 25
1636 6 12 18 24 30
1963 7 14 21 28 35
2290 8 16 24 32 40
2618 9 18 27 36 45
2945 10 20 30 40 50
3272 11 22 33 44 55
3600 12 24 36 48 60
For a 1 minute video, clip duration of 2 seconds, and interval scale 3:
mpvival 2 3 foo.mp4
How MPV is run a first and second time, showing a random start time:
mpv --start=7 --length=2 foo.mp4 ; \
mpv --start=20 --length=2 foo.mp4 ; \
mpv --start=48 --length=2 foo.mp4
mpv --start=18 --length=2 foo.mp4 ; \
mpv --start=37 --length=2 foo.mp4 ; \
mpv --start=41 --length=2 foo.mp4
OPTIONS
The interval scale number is followed by files unless a playlist flag is entered
on the command line, which must follow the scale. Usage is printed if no
arguments are given.
<mpv profile,...>
Name of the MPV profile to use.
For a 1 minute video, clip duration of 1 second, and interval scale 2:
mpvival gpu-hq 1 2 foo.mp4
How MPV is run with a random start time:
mpv --start=25 --length=1 --profile=gpu-hq foo.mp4 ; \
mpv --start=54 --length=1 --profile=gpu-hq foo.mp4
<clip duration>
How long a file should play during each interval of the total duration in
seconds.
<interval scale>
An integer between 1 and 5 where the higher the number, the more intervals and
therefore the more times the file is played. How many times the file list is
repeated with the -t option.
-l file
Plaintext playlist where each line is a file location.
For the playlist file foo.txt that contains the following two lines,
where foo1.mp4 is 1 minute and foo2.mp4 is 2 minutes:
/path/to/foo1.mp4
foo2.mp4
And command line:
mpvival 2 1 -l foo.txt
How MPV is run with a random start time:
mpv --start=21 --length=2 /path/to/foo1.mp4 ; \
mpv --start=17 --length=2 foo2.mp4 ; \
mpv --start=84 --length=2 foo2.mp4
-s file
Shuffle the file list. Options must be combined in any order with -t or -l,
for example: -tls.
-t file
Each file is played once each time the file list is repeated. With -l, options
must be combined in any order, for example: -tl.
--version
Display version information.
--help
Print this help summary.
DEPENDENCIES
FFmpeg (ffprobe)
file (command)
GNU Bourne-Again SHell (Bash)
GNU Coreutils
GNU Grep
mpv
COPYRIGHT
Unlicense <http://unlicense.org/>
This is free and unencumbered software released into the public domain and
provided without warranty of any kind.
_EOF_
elif [ '-l' = "$3" ] || [ '-ls' = "$3" ] || [ '-sl' = "$3" ] || [ '-tl' = "$3" ] || [ '-lt' = "$3" ] || [ '-lst' = "$3" ] || [ '-lts' = "$3" ] || [ '-tls' = "$3" ] || [ '-tsl' = "$3" ] || [ '-slt' = "$3" ] || [ '-stl' = "$3" ] && grep -qE "^[1-5]$" <<< "$2" && grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
swreq
_lengtho="$1"
scal="$2"
if [ '-ls' = "$3" ] || [ '-sl' = "$3" ] || [ '-lst' = "$3" ] || [ '-lts' = "$3" ] || [ '-tls' = "$3" ] || [ '-tsl' = "$3" ] || [ '-slt' = "$3" ] || [ '-stl' = "$3" ] ; then
shuffle=y
fi
if [ -r "$4" ] ; then
if file -b --mime-type "$4" | grep -q 'text/plain' ; then
if grep -q '[^[:space:]]' < "$4" ; then
fl1="$4"
if [ '-stl' = "$3" ] || [ '-slt' = "$3" ] || [ '-tsl' = "$3" ] || [ '-tls' = "$3" ] || [ '-lts' = "$3" ] || [ '-lst' = "$3" ] || [ '-lt' = "$3" ] || [ '-tl' = "$3" ] ; then
core_llt
else
core_ll
fi
else
echo >&2 "${scp}: WARNING: Empty file: $4"
echo "${scp}: Help summary: ${scp} --help"
fi
else
echo >&2 "${scp}: WARNING: A single plaintext file is expected for playlist: $4"
echo "${scp}: Help summary: ${scp} --help"
fi
else
echo >&2 "${scp}: WARNING: A single plaintext file is expected for playlist."
echo "${scp}: Help summary: ${scp} --help"
fi
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
elif [ '-t' = "$3" ] || [ '-ts' = "$3" ] || [ '-st' = "$3" ] && grep -qE "^[1-5]$" <<< "$2" && grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
swreq
_lengtho="$1"
scal="$2"
iterin=1
if [ '-ts' = "$3" ] || [ '-st' = "$3" ] ; then
shuffle=y
fi
shift 3
iall3+=("$@")
if [ -v iall3 ] ; then
for f2 in "${iall3[@]}" ; do
if [ -d "$f2" ] ; then
shopt -qs globstar
f1a="$(realpath -q "$f2")"
for f1b in "${f1a}"/** ; do
if [ -f "$f1b" ] ; then
iall2+=("$f1b")
else
continue
fi
done
elif [ -f "$f2" ] ; then
iall2+=("$f2")
else
echo >&2 "${scp}: WARNING: No such file or directory - skipping: $f2"
fi
done
if [ -v shuffle ] ; then
readarray -t iall1 < <(shuf -e "${iall2[@]}")
else
iall1+=("${iall2[@]}")
fi
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
for (( ival=1 ; ival<=scal ; ival++ )) ; do
for f1 in "${iall1[@]}" ; do
_length="$_lengtho"
dur="$(getdur)"
if ((_length > dur)) ; then
_length="$dur"
echo "${scp}: INFO: Clip duration reset: ${dur}s"
fi
idur="$dur"
ivals="$scal"
iterout=$((iterout + 1))
_start=$(shuf -i "0-$((dur - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
continue
fi
fi
core --start="$_start" --length="$_length"
unset _start
done
done
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
elif [ '-l' = "$4" ] || [ '-ls' = "$4" ] || [ '-sl' = "$4" ] || [ '-tl' = "$4" ] || [ '-lt' = "$4" ] || [ '-lst' = "$4" ] || [ '-lts' = "$4" ] || [ '-tls' = "$4" ] || [ '-tsl' = "$4" ] || [ '-slt' = "$4" ] || [ '-stl' = "$4" ] && grep -qE "^[1-5]$" <<< "$3" ; then
swreq
if grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
_lengtho="$1"
prf="$2"
scal="$3"
elif grep -qE "^[0-9]+$" <<< "$2" && (("$2" > 0)) ; then
prf="$1"
_lengtho="$2"
scal="$3"
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
if [ '-ls' = "$4" ] || [ '-sl' = "$4" ] || [ '-lst' = "$4" ] || [ '-lts' = "$4" ] || [ '-tls' = "$4" ] || [ '-tsl' = "$4" ] || [ '-slt' = "$4" ] || [ '-stl' = "$4" ] ; then
shuffle=y
fi
if [ -r "$5" ] ; then
if file -b --mime-type "$5" | grep -q 'text/plain' ; then
if grep -q '[^[:space:]]' < "$5" ; then
fl1="$5"
if [ '-stl' = "$4" ] || [ '-slt' = "$4" ] || [ '-tsl' = "$4" ] || [ '-tls' = "$4" ] || [ '-lts' = "$4" ] || [ '-lst' = "$4" ] || [ '-lt' = "$4" ] || [ '-tl' = "$4" ] ; then
core_llt --profile="$prf"
else
core_ll --profile="$prf"
fi
else
echo >&2 "${scp}: WARNING: Empty file: $5"
echo "${scp}: Help summary: ${scp} --help"
fi
else
echo >&2 "${scp}: WARNING: A single plaintext file is expected for playlist: $5"
echo "${scp}: Help summary: ${scp} --help"
fi
else
echo >&2 "${scp}: WARNING: A single plaintext file is expected for playlist."
echo "${scp}: Help summary: ${scp} --help"
fi
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
elif [ '-t' = "$4" ] || [ '-ts' = "$4" ] || [ '-st' = "$4" ] && grep -qE "^[1-5]$" <<< "$3" ; then
swreq
if grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
_lengtho="$1"
prf="$2"
scal="$3"
elif grep -qE "^[0-9]+$" <<< "$2" && (("$2" > 0)) ; then
prf="$1"
_lengtho="$2"
scal="$3"
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
iterin=1
if [ '-ts' = "$4" ] || [ '-st' = "$4" ] ; then
shuffle=y
fi
shift 4
iall3+=("$@")
if [ -v iall3 ] ; then
for f2 in "${iall3[@]}" ; do
if [ -d "$f2" ] ; then
shopt -qs globstar
f1a="$(realpath -q "$f2")"
for f1b in "${f1a}"/** ; do
if [ -f "$f1b" ] ; then
iall2+=("$f1b")
else
continue
fi
done
elif [ -f "$f2" ] ; then
iall2+=("$f2")
else
echo >&2 "${scp}: WARNING: No such file or directory - skipping: $f2"
fi
done
if [ -v shuffle ] ; then
readarray -t iall1 < <(shuf -e "${iall2[@]}")
else
iall1+=("${iall2[@]}")
fi
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
for (( ival=1 ; ival<=scal ; ival++ )) ; do
for f1 in "${iall1[@]}" ; do
_length="$_lengtho"
dur="$(getdur)"
if ((_length > dur)) ; then
_length="$dur"
echo "${scp}: INFO: Clip duration reset: ${dur}s"
fi
idur="$dur"
ivals="$scal"
iterout=$((iterout + 1))
_start=$(shuf -i "0-$((dur - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
continue
fi
fi
core --start="$_start" --length="$_length" --profile="$prf"
unset _start
done
done
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
elif [ -e "$3" ] || [ '-s' = "$3" ] && grep -qE "^[1-5]$" <<< "$2" && grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
swreq
_lengtho="$1"
scal="$2"
if [ '-s' = "$3" ] ; then
shuffle=y
shift 3
else
shift 2
fi
iall3+=("$@")
if [ -v iall3 ] ; then
for f2 in "${iall3[@]}" ; do
if [ -d "$f2" ] ; then
shopt -qs globstar
f1a="$(realpath -q "$f2")"
for f1b in "${f1a}"/** ; do
if [ -f "$f1b" ] ; then
iall2+=("$f1b")
else
continue
fi
done
elif [ -f "$f2" ] ; then
iall2+=("$f2")
else
echo >&2 "${scp}: WARNING: No such file or directory - skipping: $f2"
fi
done
if [ -v shuffle ] ; then
readarray -t iall1 < <(shuf -e "${iall2[@]}")
else
iall1+=("${iall2[@]}")
fi
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
for f1 in "${iall1[@]}" ; do
_length="$_lengtho"
dur="$(getdur)"
getiparam
for (( ival=1 ; ival<=ivals ; ival++ )) ; do
iterout=$((iterout + 1))
iterin=$((iterin + 1))
_start=$(shuf -i "$(((iterin - 1) * idur))-$((idur * iterin - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
readarray -O "$iterin" -t lpatpl <<< "$lpat"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
unset iterin
continue 2
fi
fi
core --start="$_start" --length="$_length"
done
echo "${scp}: Clip Pattern playlist: ${lpatpl[*]}"
unset lpatpl
unset _start
unset iterin
done
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
elif [ -e "$4" ] || [ '-s' = "$4" ] && grep -qE "^[1-5]$" <<< "$3" ; then
swreq
if grep -qE "^[0-9]+$" <<< "$1" && (("$1" > 0)) ; then
_lengtho="$1"
prf="$2"
scal="$3"
elif grep -qE "^[0-9]+$" <<< "$2" && (("$2" > 0)) ; then
prf="$1"
_lengtho="$2"
scal="$3"
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
if [ '-s' = "$4" ] ; then
shuffle=y
shift 4
else
shift 3
fi
iall3+=("$@")
if [ -v iall3 ] ; then
for f2 in "${iall3[@]}" ; do
if [ -d "$f2" ] ; then
shopt -qs globstar
f1a="$(realpath -q "$f2")"
for f1b in "${f1a}"/** ; do
if [ -f "$f1b" ] ; then
iall2+=("$f1b")
else
continue
fi
done
elif [ -f "$f2" ] ; then
iall2+=("$f2")
else
echo >&2 "${scp}: WARNING: No such file or directory - skipping: $f2"
fi
done
if [ -v shuffle ] ; then
readarray -t iall1 < <(shuf -e "${iall2[@]}")
else
iall1+=("${iall2[@]}")
fi
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
exit 1
fi
for f1 in "${iall1[@]}" ; do
_length="$_lengtho"
dur="$(getdur)"
getiparam
for (( ival=1 ; ival<=ivals ; ival++ )) ; do
iterout=$((iterout + 1))
iterin=$((iterin + 1))
_start=$(shuf -i "$(((iterin - 1) * idur))-$((idur * iterin - _length))" -n 1)
lpat="A${_start}0B$((_start + _length))0"
readarray -O "$iterin" -t lpatpl <<< "$lpat"
if ((iterout > 1)) ; then
uquit
if [ "$?" -eq 1 ] ; then
iterout=$((iterout - 1))
unset _start
unset iterin
continue 2
fi
fi
core --start="$_start" --length="$_length" --profile="$prf"
done
echo "${scp}: Clip Pattern playlist: ${lpatpl[*]}"
unset lpatpl
unset _start
unset iterin
done
echo "${scp}: ${iterout:-0} iterations completed - exiting..."
else
echo >&2 "${scp}: WARNING: Invalid options - aborting."
echo "${scp}: Help summary: ${scp} --help"
fi