Skip to content

Commit

Permalink
Merge pull request #109 from nulib/0.2.0a0
Browse files Browse the repository at this point in the history
0.2.0a0
  • Loading branch information
SoFrans authored Mar 5, 2024
2 parents 6db6683 + 0cac19b commit 49b6e59
Show file tree
Hide file tree
Showing 19 changed files with 1,613 additions and 873 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,7 @@ Image/Inventory/ExtraNonsenseToKeepForNow/inventory.csv

#wsl files
*.deb
*.deb.1
*.deb.1

# visual studio workspace file
*.code-workspace
Binary file removed RDCScripts_June2023.zip
Binary file not shown.
15 changes: 8 additions & 7 deletions nulrdcscripts/aproc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ In order to use all of the script's functions you will need to have the followin
## Usage
In the terminal, [navigate](#terminal-help) to the `nul-rdc-scripts` folder before running.

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

### Basic usage (--all defaults true)
### Basic usage
```
poetry run aproc -i INPUT_PATH
poetry run aproc -i INPUT_PATH -a
```

### Generate spectrograms only
### Generate spectrograms
```
poetry run aproc -i INPUT_PATH -s
```

### Generate spectrograms and skip coding (for vendors)
### Only generate qc_log
```
poetry run aproc -i INPUT_PATH -s --skip_coding
poetry run aproc -i INPUT_PATH
```

### Example File Structure
Expand All @@ -43,7 +44,7 @@ project folder (script input)
full path to input folder
`--output OUTPUT_PATH`, `-o OUTPUT_PATH`
full path to output csv file for QC results. If not specified this will default to creating a file in the input directory
`--all`, `-a` This is equivalent to using `-t -m -j -s`. Defaults to true.
`--all`, `-a` This is equivalent to using `-t -m -j -s`.
`--transcode`, `-t` transcode access files
`--write_metadata`, `-m` write Broadcast WAVE metadata to preservation file
`--write_json`, `-j` write metadata to json file
Expand Down
89 changes: 65 additions & 24 deletions nulrdcscripts/aproc/aproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ def main():
metaedit_version = corefuncs.get_bwf_metaedit_version()
sox_version = corefuncs.get_sox_version()

reference_inventory_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/inventory_reference.csv"
)
reference_inventory_list = helpers.load_reference_inventory(
reference_inventory_file
)
# verify that mediaconch policies are present
corefuncs.mediaconch_policy_exists(p_wav_policy)
corefuncs.mediaconch_policy_exists(a_wav_policy)
Expand All @@ -78,7 +71,7 @@ def main():
if args.source_inventory:
source_inventories = args.source_inventory
source_inventory_dict = helpers.import_inventories(
source_inventories, reference_inventory_list, args.skip_coding_history
source_inventories, args.skip_coding_history
)
else:
print("\n*** Checking input directory for CSV files ***")
Expand All @@ -101,7 +94,7 @@ def main():
else:
print("Inventories found\n")
source_inventory_dict = helpers.import_inventories(
source_inventories, reference_inventory_list, args.skip_coding_history
source_inventories, args.skip_coding_history
)

csvHeaderList = [
Expand Down Expand Up @@ -195,18 +188,21 @@ def main():
else:
# TODO prompt user to enter a sound mode for the file manually?
pass
coding_history_update = (
"A=PCM,F="
+ input_metadata["file metadata"]["audio sample rate"]
+ ",W="
+ input_metadata["file metadata"]["audio bitrate"]
+ ",M="
+ file_sound_mode
+ ",T=BWFMetaEdit "
+ metaedit_version
)
coding_history = coding_history + "\r\n" + coding_history_update
bwf_dict["CodingHistory"]["write"] = coding_history
# if coding history was created
if coding_history:
coding_history_update = (
"A=PCM,F="
+ input_metadata["file metadata"]["audio sample rate"]
+ ",W="
+ input_metadata["file metadata"]["audio bitrate"]
+ ",M="
+ file_sound_mode
+ ",T=BWFMetaEdit "
+ metaedit_version
)
coding_history = coding_history + "\r\n" + coding_history_update
bwf_dict["CodingHistory"]["write"] = coding_history

bwf_command = [
args.metaedit_path,
pm_file_abspath,
Expand Down Expand Up @@ -246,8 +242,6 @@ def main():
"44100",
"-c:a",
"pcm_s16le",
"-write_bext",
"1",
ac_file_abspath,
]
# sox_command = [args.sox_path, pm_file_abspath, '-b', '16', ac_file_abspath, 'rate', '44100']
Expand All @@ -261,6 +255,53 @@ def main():
"*" + base_filename + ac_identifier + access_extension,
file=f,
)
# embed BWF metadata for a file
if args.write_bwf_metadata:
print("*embedding BWF metadata*")
inventory_bwf_metadata = loaded_metadata[inventory_filename][
"BWF Metadata"
]
source_format = inventory_bwf_metadata["format"].lower()
bwf_dict["ISRF"]["write"] = source_format
# TODO coding history needs to be updated accordingly
coding_history = inventory_bwf_metadata["coding history"]
if input_metadata["file metadata"]["channels"] == 1:
file_sound_mode = "mono"
elif input_metadata["file metadata"]["channels"] == 2:
file_sound_mode = "stereo"
else:
# TODO prompt user to enter a sound mode for the file manually?
pass
# if coding history was created
if coding_history:
coding_history_update = (
"A=PCM,F="
+ input_metadata["file metadata"]["audio sample rate"]
+ ",W="
+ input_metadata["file metadata"]["audio bitrate"]
+ ",M="
+ file_sound_mode
+ ",T=BWFMetaEdit "
+ metaedit_version
)
coding_history = coding_history + "\r\n" + coding_history_update
bwf_dict["CodingHistory"]["write"] = coding_history

bwf_command = [
args.metaedit_path,
ac_file_abspath,
"--MD5-Embed",
"--BextVersion=1",
]
for key in bwf_dict:
if bwf_dict[key]["write"]:
bwf_command += [
bwf_dict[key]["command"] + bwf_dict[key]["write"]
]
# if args.reset_timereference:
# bwf_command += ['--Timereference=' + '0']
subprocess.run(bwf_command)
# print(bwf_command)

# create folder for metadata if needed
if args.spectrogram or args.write_json:
Expand Down Expand Up @@ -305,7 +346,7 @@ def main():
ac_file_abspath, a_wav_policy
),
"Access BWF Policy": helpers.mediaconch_policy_check(
pm_file_abspath, bwf_policy
ac_file_abspath, bwf_policy
),
}
# PASS/FAIL - check if any mediaconch results failed and append failed policies to results
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<policy type="and" name="P0391-CAGE-B154I11_v01s01-p.wav">
<rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
<rule name="General/FileExtension is wav" value="FileExtension" tracktype="General" occurrence="*" operator="=">wav</rule>
<rule name="General/Format is Wave" value="Format" tracktype="General" occurrence="*" operator="=">Wave</rule>
<rule name="General/OverallBitRate_Mode is CBR" value="OverallBitRate_Mode" tracktype="General" occurrence="*" operator="=">CBR</rule>
<rule name="Audio/Format is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
<rule name="Audio/Format_Settings_Endianness is Little" value="Format_Settings_Endianness" tracktype="Audio" occurrence="*" operator="=">Little</rule>
<rule name="Audio/Format_Settings_Sign is Signed" value="Format_Settings_Sign" tracktype="Audio" occurrence="*" operator="=">Signed</rule>
<rule name="Audio/CodecID is 1" value="CodecID" tracktype="Audio" occurrence="*" operator="=">1</rule>
<rule name="Audio/BitRate_Mode is CBR" value="BitRate_Mode" tracktype="Audio" occurrence="*" operator="=">CBR</rule>
<rule name="Audio/Channels is 2" value="Channels" tracktype="Audio" occurrence="*" operator="&gt;">0</rule>
<rule name="Audio/SamplingRate is 48000" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
<rule name="Audio/BitDepth is 16" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
<rule name="Audio/Delay_Source is Container (bext)" value="Delay_Source" tracktype="Audio" occurrence="*" operator="=">Container (bext)</rule>
</policy>
Loading

0 comments on commit 49b6e59

Please sign in to comment.