Skip to content

Commit 49b6e59

Browse files
authored
Merge pull request #109 from nulib/0.2.0a0
0.2.0a0
2 parents 6db6683 + 0cac19b commit 49b6e59

File tree

19 files changed

+1613
-873
lines changed

19 files changed

+1613
-873
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,7 @@ Image/Inventory/ExtraNonsenseToKeepForNow/inventory.csv
146146

147147
#wsl files
148148
*.deb
149-
*.deb.1
149+
*.deb.1
150+
151+
# visual studio workspace file
152+
*.code-workspace

RDCScripts_June2023.zip

-829 KB
Binary file not shown.

nulrdcscripts/aproc/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ In order to use all of the script's functions you will need to have the followin
77
## Usage
88
In the terminal, [navigate](#terminal-help) to the `nul-rdc-scripts` folder before running.
99

10-
**Note: make sure valid inventory csv is in the input folder**
10+
**Note: make sure valid inventory csv is in the input folder**
11+
**Note: qc_log is always generated (mediaconch policies are always checked)**
1112

12-
### Basic usage (--all defaults true)
13+
### Basic usage
1314
```
14-
poetry run aproc -i INPUT_PATH
15+
poetry run aproc -i INPUT_PATH -a
1516
```
1617

17-
### Generate spectrograms only
18+
### Generate spectrograms
1819
```
1920
poetry run aproc -i INPUT_PATH -s
2021
```
2122

22-
### Generate spectrograms and skip coding (for vendors)
23+
### Only generate qc_log
2324
```
24-
poetry run aproc -i INPUT_PATH -s --skip_coding
25+
poetry run aproc -i INPUT_PATH
2526
```
2627

2728
### Example File Structure
@@ -43,7 +44,7 @@ project folder (script input)
4344
full path to input folder
4445
`--output OUTPUT_PATH`, `-o OUTPUT_PATH`
4546
full path to output csv file for QC results. If not specified this will default to creating a file in the input directory
46-
`--all`, `-a` This is equivalent to using `-t -m -j -s`. Defaults to true.
47+
`--all`, `-a` This is equivalent to using `-t -m -j -s`.
4748
`--transcode`, `-t` transcode access files
4849
`--write_metadata`, `-m` write Broadcast WAVE metadata to preservation file
4950
`--write_json`, `-j` write metadata to json file

nulrdcscripts/aproc/aproc.py

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ def main():
5858
metaedit_version = corefuncs.get_bwf_metaedit_version()
5959
sox_version = corefuncs.get_sox_version()
6060

61-
reference_inventory_file = os.path.join(
62-
os.path.dirname(os.path.abspath(__file__)),
63-
"data/inventory_reference.csv"
64-
)
65-
reference_inventory_list = helpers.load_reference_inventory(
66-
reference_inventory_file
67-
)
6861
# verify that mediaconch policies are present
6962
corefuncs.mediaconch_policy_exists(p_wav_policy)
7063
corefuncs.mediaconch_policy_exists(a_wav_policy)
@@ -78,7 +71,7 @@ def main():
7871
if args.source_inventory:
7972
source_inventories = args.source_inventory
8073
source_inventory_dict = helpers.import_inventories(
81-
source_inventories, reference_inventory_list, args.skip_coding_history
74+
source_inventories, args.skip_coding_history
8275
)
8376
else:
8477
print("\n*** Checking input directory for CSV files ***")
@@ -101,7 +94,7 @@ def main():
10194
else:
10295
print("Inventories found\n")
10396
source_inventory_dict = helpers.import_inventories(
104-
source_inventories, reference_inventory_list, args.skip_coding_history
97+
source_inventories, args.skip_coding_history
10598
)
10699

107100
csvHeaderList = [
@@ -195,18 +188,21 @@ def main():
195188
else:
196189
# TODO prompt user to enter a sound mode for the file manually?
197190
pass
198-
coding_history_update = (
199-
"A=PCM,F="
200-
+ input_metadata["file metadata"]["audio sample rate"]
201-
+ ",W="
202-
+ input_metadata["file metadata"]["audio bitrate"]
203-
+ ",M="
204-
+ file_sound_mode
205-
+ ",T=BWFMetaEdit "
206-
+ metaedit_version
207-
)
208-
coding_history = coding_history + "\r\n" + coding_history_update
209-
bwf_dict["CodingHistory"]["write"] = coding_history
191+
# if coding history was created
192+
if coding_history:
193+
coding_history_update = (
194+
"A=PCM,F="
195+
+ input_metadata["file metadata"]["audio sample rate"]
196+
+ ",W="
197+
+ input_metadata["file metadata"]["audio bitrate"]
198+
+ ",M="
199+
+ file_sound_mode
200+
+ ",T=BWFMetaEdit "
201+
+ metaedit_version
202+
)
203+
coding_history = coding_history + "\r\n" + coding_history_update
204+
bwf_dict["CodingHistory"]["write"] = coding_history
205+
210206
bwf_command = [
211207
args.metaedit_path,
212208
pm_file_abspath,
@@ -246,8 +242,6 @@ def main():
246242
"44100",
247243
"-c:a",
248244
"pcm_s16le",
249-
"-write_bext",
250-
"1",
251245
ac_file_abspath,
252246
]
253247
# sox_command = [args.sox_path, pm_file_abspath, '-b', '16', ac_file_abspath, 'rate', '44100']
@@ -261,6 +255,53 @@ def main():
261255
"*" + base_filename + ac_identifier + access_extension,
262256
file=f,
263257
)
258+
# embed BWF metadata for a file
259+
if args.write_bwf_metadata:
260+
print("*embedding BWF metadata*")
261+
inventory_bwf_metadata = loaded_metadata[inventory_filename][
262+
"BWF Metadata"
263+
]
264+
source_format = inventory_bwf_metadata["format"].lower()
265+
bwf_dict["ISRF"]["write"] = source_format
266+
# TODO coding history needs to be updated accordingly
267+
coding_history = inventory_bwf_metadata["coding history"]
268+
if input_metadata["file metadata"]["channels"] == 1:
269+
file_sound_mode = "mono"
270+
elif input_metadata["file metadata"]["channels"] == 2:
271+
file_sound_mode = "stereo"
272+
else:
273+
# TODO prompt user to enter a sound mode for the file manually?
274+
pass
275+
# if coding history was created
276+
if coding_history:
277+
coding_history_update = (
278+
"A=PCM,F="
279+
+ input_metadata["file metadata"]["audio sample rate"]
280+
+ ",W="
281+
+ input_metadata["file metadata"]["audio bitrate"]
282+
+ ",M="
283+
+ file_sound_mode
284+
+ ",T=BWFMetaEdit "
285+
+ metaedit_version
286+
)
287+
coding_history = coding_history + "\r\n" + coding_history_update
288+
bwf_dict["CodingHistory"]["write"] = coding_history
289+
290+
bwf_command = [
291+
args.metaedit_path,
292+
ac_file_abspath,
293+
"--MD5-Embed",
294+
"--BextVersion=1",
295+
]
296+
for key in bwf_dict:
297+
if bwf_dict[key]["write"]:
298+
bwf_command += [
299+
bwf_dict[key]["command"] + bwf_dict[key]["write"]
300+
]
301+
# if args.reset_timereference:
302+
# bwf_command += ['--Timereference=' + '0']
303+
subprocess.run(bwf_command)
304+
# print(bwf_command)
264305

265306
# create folder for metadata if needed
266307
if args.spectrogram or args.write_json:
@@ -305,7 +346,7 @@ def main():
305346
ac_file_abspath, a_wav_policy
306347
),
307348
"Access BWF Policy": helpers.mediaconch_policy_check(
308-
pm_file_abspath, bwf_policy
349+
ac_file_abspath, bwf_policy
309350
),
310351
}
311352
# PASS/FAIL - check if any mediaconch results failed and append failed policies to results
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<policy type="and" name="P0391-CAGE-B154I11_v01s01-p.wav">
3+
<rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
4+
<rule name="General/FileExtension is wav" value="FileExtension" tracktype="General" occurrence="*" operator="=">wav</rule>
5+
<rule name="General/Format is Wave" value="Format" tracktype="General" occurrence="*" operator="=">Wave</rule>
6+
<rule name="General/OverallBitRate_Mode is CBR" value="OverallBitRate_Mode" tracktype="General" occurrence="*" operator="=">CBR</rule>
7+
<rule name="Audio/Format is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
8+
<rule name="Audio/Format_Settings_Endianness is Little" value="Format_Settings_Endianness" tracktype="Audio" occurrence="*" operator="=">Little</rule>
9+
<rule name="Audio/Format_Settings_Sign is Signed" value="Format_Settings_Sign" tracktype="Audio" occurrence="*" operator="=">Signed</rule>
10+
<rule name="Audio/CodecID is 1" value="CodecID" tracktype="Audio" occurrence="*" operator="=">1</rule>
11+
<rule name="Audio/BitRate_Mode is CBR" value="BitRate_Mode" tracktype="Audio" occurrence="*" operator="=">CBR</rule>
12+
<rule name="Audio/Channels is 2" value="Channels" tracktype="Audio" occurrence="*" operator="&gt;">0</rule>
13+
<rule name="Audio/SamplingRate is 48000" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
14+
<rule name="Audio/BitDepth is 16" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
15+
<rule name="Audio/Delay_Source is Container (bext)" value="Delay_Source" tracktype="Audio" occurrence="*" operator="=">Container (bext)</rule>
16+
</policy>

0 commit comments

Comments
 (0)