@@ -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
0 commit comments