-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
647 lines (557 loc) · 25.3 KB
/
main.py
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
import argparse
import os
from constants import *
import shutil
import subprocess
import json
parser = argparse.ArgumentParser(
prog='spatial-creator',
description='Turning stereo music into surround or Dolby Atmos',
epilog='Copyright (c) Floofi Systems')
parser.add_argument('input')
parser.add_argument('scene')
parser.add_argument('-o', '--output')
args = _args = parser.parse_args()
if not os.path.exists(args.input):
print(f'Input file {args.input} not found')
exit(1)
if os.path.isdir(args.input):
print(f"Notice: {args.input} is a directory, using the first file in this directory as the reference input.")
args.input = list(os.scandir(args.input))[0].path
if not os.path.exists(args.scene):
print(f'Scene file {args.scene} not found')
exit(1)
if args.output is not None and os.path.exists(args.output):
print(f'Output file {args.output} already exists')
exit(1)
output = args.output
input_file = args.input
with open(args.scene, 'r') as f:
file = f.read()
constants = sorted(list(Constants.items()), key=lambda x: len(x[0]), reverse=True)
for (name, value) in constants:
file = file.replace(name, str(value))
lines = list(filter(lambda x: x.strip() != "" and not x.strip().startswith("'"), file.splitlines()))
if not lines[0].startswith("%Srdr-"):
print("Invalid signature in scene file")
exit(1)
version = lines[0].split("-")[1]
if version not in Versions:
print(f"This version of Spatial Creator does not support this Scene file. Supported versions: {', '.join(Versions)}")
exit(1)
if Versions.index(version) == len(Versions) - 1:
print(f"Floofi Spatial Creator {Version}, using Scene specification version {version} (native)")
else:
print(f"Floofi Spatial Creator {Version}, using Scene specification version {version} (compatibility)")
operations = []
for line in lines[1:]:
operation_name = line.split(":")[0]
parameters = list(map(lambda x: x.strip(), line.split(":")[1].split(";")))
operations.append((operation_name, parameters))
channels = 0
bit_depth = 0
sample_rate = 0
sample_format = "s16"
layout = None
if os.path.exists("./srdr_work"):
shutil.rmtree('./srdr_work')
os.mkdir('./srdr_work')
os.mkdir('./srdr_work/channels')
input_metadata = json.loads(subprocess.run([
"ffprobe",
"-v",
"quiet",
"-print_format",
"json",
"-show_format",
"-show_streams",
args.input
], stdout=subprocess.PIPE).stdout)
streams = list(filter(lambda x: x['codec_type'] == "audio", input_metadata['streams']))
if len(streams) < 1:
print("The input file does not contain audio streams.")
exit(1)
if len(streams) > 1:
print("Warning: The input file contains multiple audio streams, only the first one will be used.")
exit(1)
source = streams[0]
if 'bit_rate' in source:
print(f"Input: {source['codec_long_name']}, "
f"{int(source['sample_rate']) / 1000} kHz, "
f"{int(source['bit_rate']) / 1000} kbps, "
f"{source['duration']} seconds")
else:
print(f"Input: {source['codec_long_name']}, "
f"{int(source['sample_rate']) / 1000} kHz, "
f"{source['duration']} seconds")
for (name, parameters) in operations:
match name:
case "Chs":
if len(parameters) != 3:
print(f"Expected 3 parameters but got {len(parameters)}.")
exit(2)
try:
channels = int(parameters[0])
if version == "1.0" or version == "1.1" or version == "1.2" or version == "1.3":
if not 2 < channels < 65536:
print(f"Invalid number of channels {channels}, there must be between 3 and 65535 channels.")
exit(2)
else:
if not 1 < channels < 65536:
print(f"Invalid number of channels {channels}, there must be between 2 and 65535 channels.")
exit(2)
print(f"Channels: {channels}")
except ValueError:
print(f"Invalid number for channel number: {parameters[0]}")
exit(2)
try:
bit_depth = int(parameters[1])
if bit_depth != 16 and bit_depth != 24 and bit_depth != 32:
print(f"Invalid bit depth {bit_depth}, bit depth must be 16, 24 or 32.")
exit(2)
match bit_depth:
case 16:
sample_rate = "s16"
case 24:
sample_rate = "s32p"
case 32:
sample_rate = "s32"
print(f"Bit depth: {bit_depth} bit")
except ValueError:
print(f"Invalid number for bit depth: {parameters[1]}")
exit(2)
try:
sample_rate = int(parameters[2])
if not 22050 <= sample_rate <= 384000:
print(f"Invalid sample rate {sample_rate}, sample rate must be between 22050 and 384000 Hz.")
exit(2)
print(f"Sample rate: {sample_rate} Hz ({sample_rate / 1000} kHz)")
except ValueError:
print(f"Invalid number for bit depth: {parameters[1]}")
exit(2)
print("Processing input...")
subprocess.run([
"ffmpeg",
"-y",
"-i", f"{_args.input}",
"-ar", f"{sample_rate}",
"-c:a", f"pcm_s{bit_depth}le",
f"./srdr_work/input.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
for i in range(channels):
subprocess.run([
"ffmpeg",
"-y",
"-f", "lavfi",
"-i", f"anullsrc=channel_layout=mono:sample_rate={sample_rate}",
"-t", f"{source['duration']}",
"-c:a", f"pcm_s{bit_depth}le",
f"./srdr_work/channels/{i}.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
case "Sep":
if version == "1.0" or version == "1.1":
if len(parameters) != 1:
print(f"Expected 1 parameter but got {len(parameters)}.")
exit(2)
else:
if len(parameters) < 1:
print(f"Expected at least 1 parameter but got {len(parameters)}.")
exit(2)
if not os.path.exists(f"./srdr_work/input.wav"):
print(f"Separation is not ready: not configured.")
exit(2)
try:
stem_format = int(parameters[0])
except ValueError:
print(f"Invalid stem format value: {parameters[0]}")
exit(2)
args = ["--float32", "-n", "htdemucs_6s", "-o", "./srdr_work/stems_tmp"]
if stem_format == -2:
if not os.path.exists(f"./stems"):
print("Could not find stems in a 'stems' folder.")
exit(2)
shutil.copytree(f"./stems", f"./srdr_work/stems")
elif stem_format == -1 or (stem_format == -3 and version != "1.0" and version != "1.1" and version != "1.2" and version != "1.3"):
pass
else:
if len(parameters) != 2:
print(f"Expected 2 parameters but got {len(parameters)}.")
exit(2)
if version != "1.0" and version != "1.1":
args[2] = parameters[1]
print(f"Using model {args[2]}")
args.append("./srdr_work/input.wav")
match stem_format:
case 0:
pass
case 1:
print("Isolating vocals")
args.append("--two-stems")
args.append("vocals")
case 2:
print("Isolating bass")
args.append("--two-stems")
args.append("bass")
case 3:
print("Isolating piano")
args.append("--two-stems")
args.append("piano")
case 4:
print("Isolating guitar")
args.append("--two-stems")
args.append("guitar")
case 5:
print("Isolating drums")
args.append("--two-stems")
args.append("drums")
case 6:
print("Isolating other")
args.append("--two-stems")
args.append("other")
case _:
print(f"Invalid separation configuration: {stem_format}")
exit(2)
if stem_format > -1:
import demucs.separate
print("Separating using machine learning, this might take a while.")
demucs.separate.main(args)
os.rename(f"./srdr_work/stems_tmp/{args[2]}/input", "./srdr_work/stems")
shutil.rmtree('./srdr_work/stems_tmp')
elif stem_format == -1:
os.mkdir("./srdr_work/stems")
subprocess.run([
"sox",
"./srdr_work/input.wav",
"./srdr_work/stems/other.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"sox",
"./srdr_work/input.wav",
"./srdr_work/stems/vocals.wav",
"highpass", "300",
"lowpass", "3500"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
elif stem_format == -3 and version != "1.0" and version != "1.1" and version != "1.2" and version != "1.3":
os.mkdir("./srdr_work/stems")
subprocess.run([
"ffmpeg",
"-i", "./srdr_work/input.wav",
"./srdr_work/stems/other.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/vocals.wav"):
os.rename("./srdr_work/stems/vocals.wav", "./srdr_work/stems/1.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/1.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/8.wav",
"-map", "[right]",
"./srdr_work/stems/9.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/bass.wav"):
os.rename("./srdr_work/stems/bass.wav", "./srdr_work/stems/2.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/2.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/10.wav",
"-map", "[right]",
"./srdr_work/stems/11.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/piano.wav"):
os.rename("./srdr_work/stems/piano.wav", "./srdr_work/stems/3.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/3.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/12.wav",
"-map", "[right]",
"./srdr_work/stems/13.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/guitar.wav"):
os.rename("./srdr_work/stems/guitar.wav", "./srdr_work/stems/4.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/4.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/14.wav",
"-map", "[right]",
"./srdr_work/stems/15.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/drums.wav"):
os.rename("./srdr_work/stems/drums.wav", "./srdr_work/stems/5.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/5.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/16.wav",
"-map", "[right]",
"./srdr_work/stems/17.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists("./srdr_work/stems/other.wav"):
os.rename("./srdr_work/stems/other.wav", "./srdr_work/stems/6.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/6.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/18.wav",
"-map", "[right]",
"./srdr_work/stems/19.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"sox",
"./srdr_work/input.wav",
"./srdr_work/stems/7.wav",
"remix", "1,2",
"lowpass", "120"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/stems/7.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
"./srdr_work/stems/20.wav",
"-map", "[right]",
"./srdr_work/stems/21.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
case "Map":
if len(parameters) != 3:
print(f"Expected 3 parameters but got {len(parameters)}.")
exit(2)
try:
stem = int(parameters[0])
except ValueError:
print(f"Invalid stem value: {parameters[0]}")
exit(2)
try:
channel = int(parameters[1])
except ValueError:
print(f"Invalid channel value: {parameters[1]}")
exit(2)
try:
gain = float(parameters[2])
except ValueError:
print(f"Invalid gain value: {parameters[2]}")
exit(2)
if not os.path.exists(f"./srdr_work/channels/{channel}.wav"):
print(f"Invalid or nonexistent channel: {channel}")
exit(2)
if not os.path.exists(f"./srdr_work/stems/{stem}.wav"):
print(f"Invalid or nonexistent stem: {stem}")
exit(2)
if stem < 8:
print(f"Stem {stem} is stereo and cannot be mapped to a channel.")
exit(2)
if layout is not None:
print(f"Mapping: Stem {stem} ({value_to_constant(stem, 'STEMS_')}) -> Channel {channel} ({layout[channel]})")
else:
print(f"Mapping: Stem {stem} ({value_to_constant(stem, 'STEMS_')}) -> Channel {channel}")
subprocess.run([
"ffmpeg",
"-y",
"-i", f"./srdr_work/stems/{stem}.wav",
"-af", f"volume={gain}",
f"./srdr_work/stems/{stem}_2.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"ffmpeg",
"-y",
"-i", f"./srdr_work/channels/{channel}.wav",
"-i", f"./srdr_work/stems/{stem}_2.wav",
"-filter_complex", "amix=inputs=2:duration=longest",
f"./srdr_work/channels/{channel}_2.wav",
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink(f"./srdr_work/channels/{channel}.wav")
os.unlink(f"./srdr_work/stems/{stem}_2.wav")
os.rename(f"./srdr_work/channels/{channel}_2.wav", f"./srdr_work/channels/{channel}.wav")
case "Dis":
if version == "1.0":
print(f"This Scene file does not support the Dis instruction.")
exit(2)
if len(parameters) != 2:
print(f"Expected 2 parameters but got {len(parameters)}.")
exit(2)
try:
channel1 = int(parameters[0])
except ValueError:
print(f"Invalid channel value: {parameters[0]}")
exit(2)
try:
channel2 = int(parameters[1])
except ValueError:
print(f"Invalid channel value: {parameters[1]}")
exit(2)
if not os.path.exists(f"./srdr_work/channels/{channel1}.wav"):
print(f"Invalid or nonexistent channel: {channel1}")
exit(2)
if not os.path.exists(f"./srdr_work/channels/{channel2}.wav"):
print(f"Invalid or nonexistent channel: {channel2}")
exit(2)
if layout is not None:
print(f"Distance: Channel {channel1} ({layout[channel1]}) <-> Channel {channel2} ({layout[channel2]})")
else:
print(f"Distance: Channel {channel1} <-> Channel {channel2}")
subprocess.run([
"sox",
"-M",
f"./srdr_work/channels/{channel1}.wav",
f"./srdr_work/channels/{channel2}.wav",
f"./srdr_work/channels/_2.wav",
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"sox",
f"./srdr_work/channels/_2.wav",
f"./srdr_work/channels/_3.wav",
"remix", "1v-0.8718,2v0.4898", "1v0.4898,2v-0.8718",
"delay", "0.15"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/channels/_3.wav",
"-filter_complex", "[0:0]pan=1|c0=c0[left];[0:0]pan=1|c0=c1[right]",
"-map", "[left]",
f"./srdr_work/channels/{channel1}_2.wav",
"-map", "[right]",
f"./srdr_work/channels/{channel2}_2.wav",
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink(f"./srdr_work/channels/{channel1}.wav")
os.unlink(f"./srdr_work/channels/{channel2}.wav")
os.unlink(f"./srdr_work/channels/_2.wav")
os.unlink(f"./srdr_work/channels/_3.wav")
os.rename(f"./srdr_work/channels/{channel1}_2.wav", f"./srdr_work/channels/{channel1}.wav")
os.rename(f"./srdr_work/channels/{channel2}_2.wav", f"./srdr_work/channels/{channel2}.wav")
case "Lay":
layout = parameters
for channel in layout:
if channel not in Channels:
print(f"Invalid audio channel label: {channel}")
exit(2)
print(f"Channel layout: {', '.join(layout)}")
case "Out":
output_filter = 0
if version == "1.0" or version == "1.1" or version == "1.2" or version == "1.3":
if len(parameters) != 1:
print(f"Expected 1 parameter but got {len(parameters)}.")
exit(2)
else:
if len(parameters) != 2:
print(f"Expected 2 parameters but got {len(parameters)}.")
exit(2)
try:
output_filter = int(parameters[1])
except ValueError:
print(f"Invalid output filter: {parameters[1]}")
exit(2)
if not os.path.exists(f"./srdr_work/input.wav"):
print(f"Output is not ready: not configured.")
exit(2)
try:
output_format = int(parameters[0])
except ValueError:
print(f"Invalid output format value: {parameters[0]}")
exit(2)
extra_args = []
match output_format:
case 0: # WAV
print("Output format: RIFF WAVE")
extension = ".wav"
case 1: # FLAC
print("Output format: Free Lossless Audio Codec")
if channels > 8:
print(f"Free Lossless Audio Codec only supports up to 8 channels, but {channels} are used.")
exit(2)
extension = ".flac"
case 2: # AC-3
print("Output format: Dolby AC-3")
if channels > 6:
print(f"Dolby AC-3 only supports up to 6 channels, but {channels} are used.")
exit(2)
extension = ".ac3"
case 3: # E-AC-3
print("Output format: Dolby E-AC-3")
if channels > 6:
print(f"Dolby E-AC-3 only supports up to 6 channels, but {channels} are used.")
exit(2)
extension = ".eac3"
case 4: # AC-4
print("Output format: Dolby AC-4")
print("Dolby AC-4 is not supported in this version. Please select another codec.")
exit(2)
case 5: # AAC
print("Output format: Advanced Audio Coding")
if channels > 48:
print(f"Advanced Audio Coding only supports up to 48 channels, but {channels} are used.")
exit(2)
extension = ".aac"
case 6: # TrueHD
print("Output format: Dolby TrueHD")
print("Warning: Dolby TrueHD support is experimental and may cause issues.")
if channels > 15:
print(f"Dolby TrueHD only supports up to 15 channels, but {channels} are used.")
exit(2)
extension = ".thd"
extra_args += ["-strict", "-2"]
case _:
print(f"Invalid or unsupported output format: {output_format}")
exit(2)
args = ["sox", "-M"]
for i in range(channels):
args.append(f"./srdr_work/channels/{i}.wav")
args += [
"-r", str(sample_rate),
"-b", str(bit_depth),
f"./srdr_work/output.wav"
]
subprocess.run(args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if layout is not None:
audio_filter = "join=inputs=1:channel_layout="
for channel in layout:
audio_filter += f"{channel}+"
audio_filter = audio_filter[:-1]
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/output.wav",
"-filter_complex", audio_filter,
"./srdr_work/output_2.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink("./srdr_work/output.wav")
os.rename("./srdr_work/output_2.wav", "./srdr_work/output.wav")
if output_filter == 1:
print("Impulse response files are Copyright (C) 2005 Aalto University; <http://legacy.spa.aalto.fi/projects/poririrs/>")
if channels > 5:
print(f"Warning: Concert filters are optimized for 5 channels or less. You are using {channels} channels, which may affect the final result.")
subprocess.run([
"ffmpeg",
"-i", f"./srdr_work/output.wav",
"-i", "./ir.wav",
"-lavfi", "afir,volume=50",
f"./srdr_work/output_2.wav"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink("./srdr_work/output.wav")
os.rename("./srdr_work/output_2.wav", "./srdr_work/output.wav")
subprocess.run([
"ffmpeg",
"-y",
"-i", "./srdr_work/output.wav",
*extra_args,
f"./srdr_work/final{extension}"
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.rename(f"./srdr_work/final{extension}", os.path.splitext(input_file)[0] + f"_fsc{extension}")
case _:
print(f"Invalid or unsupported command in this version: {name}")
exit(2)