def test_monoaural_aiff(self): new_file = os.path.join(common.sandbox(), 'ama_aiff.aaf') with aaf2.open(new_file, 'w') as f: aiff_file = common.generate_pcm_audio_mono('test_ama_aiff', fmt='aiff') meta = common.probe(aiff_file) mobs = ama.create_media_link(f, aiff_file, meta) self.assertTrue(len(mobs), 3) with aaf2.open(new_file, 'r') as f: common.walk_aaf(f.root) self.assertTrue(len(f.content.mobs) == 3) self.assertTrue(len(list(f.content.mastermobs())) == 1) master_mob = next(f.content.mastermobs()) self.assert_mastermob_valid_edit_spec(master_mob=master_mob, expected_sound_slots=1, expected_picture_slots=0) self.assertEqual(len(master_mob.slots), 1, "MasterMob should only have one slot") self.assertEqual(master_mob.slots[0].media_kind, 'Sound', "MasterMob slot has incorrect media_kind") source_clip = master_mob.slots[0].segment.components[0] descriptor = source_clip.mob.descriptor self.assertIsNotNone(descriptor, "File SourceMob has no WAVEDescriptor") self.assertIsInstance(descriptor, aaf2.essence.AIFCDescriptor, "File SourceMob has no AIFCDescriptor") self.assertIsNotNone( descriptor['Summary'].value, "AIFCDescriptor missing required 'Summary' property")
def test_basic_audio_link(self): audio_profile_name = 'pcm_48000_s24le' sample_format = audio.pcm_profiles[audio_profile_name]['sample_format'] sample_rate = audio.pcm_profiles[audio_profile_name]['sample_rate'] audio_duration = 1 audio_sample = common.generate_pcm_audio_mono( audio_profile_name, sample_format=sample_format, sample_rate=sample_rate, duration=audio_duration, fmt='mxf_opatom') meta = common.probe(audio_sample) audio_mob_id = mobid.MobID( meta['format']['tags']['material_package_umid']) audio_source_mob_id = mobid.MobID( meta['streams'][0]['tags']['file_package_umid']) new_file = os.path.join(common.sandbox(), 'mxf_link_audio.aaf') with aaf2.open(new_file, 'w') as f: f.content.link_external_mxf(audio_sample) with aaf2.open(new_file, 'r') as f: assert len(f.content.mobs) == 2 for mob in f.content.mobs: if isinstance(mob, mobs.MasterMob): assert mob.mob_id == audio_mob_id elif isinstance(mob, mobs.SourceMob): if isinstance(mob.descriptor, essence.PCMDescriptor): assert mob.mob_id == audio_source_mob_id
def test_basic_video_link(self): profile_name = 'dnx_1080p_36_23.97' video_sample = common.generate_dnxhd(profile_name, "mxf_link_video.mxf", 10, fmt='mxf_opatom') meta = common.probe(video_sample) video_mob_id = mobid.MobID( meta['format']['tags']['material_package_umid']) video_source_mob_id = mobid.MobID( meta['streams'][0]['tags']['file_package_umid']) new_file = os.path.join(common.sandbox(), 'mxf_link_video.aaf') with aaf2.open(new_file, 'w') as f: f.content.link_external_mxf(video_sample) with aaf2.open(new_file, 'r') as f: assert len(f.content.mobs) == 2 for mob in f.content.mobs: if isinstance(mob, mobs.MasterMob): assert mob.mob_id == video_mob_id elif isinstance(mob, mobs.SourceMob): if isinstance(mob.descriptor, essence.CDCIDescriptor): assert mob.mob_id == video_source_mob_id
def test_wav_link(self): test_outfile = os.path.join(common.sandbox(), 'wav_link.aaf') test_link_targets = [ common.generate_pcm_audio_mono('testmono', sample_rate=48000, duration=10, sample_format='pcm_s16le', fmt='wav'), common.generate_pcm_audio_mono('testmono24', sample_rate=48000, duration=10, sample_format='pcm_s24le', fmt='wav'), common.generate_pcm_audio_stereo('testmono', sample_rate=48000, duration=10, sample_format='pcm_s24le', fmt='wav') ] with aaf2.open(test_outfile, 'w') as f: for target in test_link_targets: meta = common.probe(target) mobs = f.content.link_external_wav(meta)
def test_prores(self): new_file = os.path.join(common.sandbox(), 'prores_mov.aaf') with aaf2.open(new_file, 'w') as f: for profile, name in prores_profiles: vcodec = ['-c:v', 'prores_ks', '-profile:v', str(profile)] mov = common.generate_mov('ama_prores_%s.mov' % (name, ), overwrite=False, vcodec=vcodec) meta = common.probe(mov) mobs = f.content.create_ama_link(mov, meta) # for (pix_fmt, profile) in avc_profiles: with aaf2.open(new_file, 'r') as f: common.walk_aaf(f.root)
def test_avc_mov(self): new_file = os.path.join(common.sandbox(), 'avc_mov.aaf') audio_channel_count = 2 created_mastermob_ids = [] with aaf2.open(new_file, 'w') as f: for (pix_fmt, profile) in avc_profiles: vcodec = [ '-pix_fmt', pix_fmt, '-c:v', 'h264', '-profile:v', profile ] mov = common.generate_mov('ama_avc_%s.mov' % profile, overwrite=False, vcodec=vcodec, audio_channels=audio_channel_count) meta = common.probe(mov) # print(meta['streams'][0]['profile']) mobs = f.content.create_ama_link(mov, meta) self.assertEqual(len(mobs), 3) self.assertIsInstance(mobs[0], aaf2.mobs.MasterMob) self.assertIsInstance(mobs[1], aaf2.mobs.SourceMob) self.assertIsInstance(mobs[2], aaf2.mobs.SourceMob) created_mastermob_ids.append(mobs[0].mob_id) with aaf2.open(new_file, 'r') as f: common.walk_aaf(f.root) self.assertEqual( len(f.content.mobs), len(avc_profiles) * 3, "Failed to create exactly three MOBs per avc_profile") self.assertEqual( len(list(f.content.mastermobs())), len(avc_profiles), "Failed to create exactly one MasterMOB per avc_profile") for mastermob_id in created_mastermob_ids: mastermob = next( (mob for mob in f.content.mobs if mob.mob_id == mastermob_id), None) self.assert_mastermob_valid_edit_spec(mastermob, expected_picture_slots=1, expected_sound_slots=2) self.assert_valid_multiple_descriptor(mastermob, audio_channel_count)
def test_avc_mov(self): new_file = os.path.join(common.sandbox(), 'avc_mov.aaf') with aaf2.open(new_file, 'w') as f: for (pix_fmt, profile) in avc_profiles: vcodec = [ '-pix_fmt', pix_fmt, '-c:v', 'h264', '-profile:v', profile ] mov = common.generate_mov('ama_avc_%s.mov' % profile, overwrite=False, vcodec=vcodec) meta = common.probe(mov) # print(meta['streams'][0]['profile']) mobs = f.content.create_ama_link(mov, meta) with aaf2.open(new_file, 'r') as f: common.walk_aaf(f.root)
def test_prores(self): new_file = os.path.join(common.sandbox(), 'prores_mov.aaf') created_mastermob_ids = [] with aaf2.open(new_file, 'w') as f: for profile, name in prores_profiles: vcodec = ['-c:v', 'prores_ks', '-profile:v', str(profile)] mov = common.generate_mov('ama_prores_%s.mov' % (name, ), overwrite=False, vcodec=vcodec, audio_channels=2) meta = common.probe(mov) mobs = ama.create_media_link(f, mov, meta) self.assertEqual( len(mobs), 3, "create_ama_link must return exactly three mobs") created_mastermob_ids.append(mobs[0].mob_id) with aaf2.open(new_file, 'r') as f: common.walk_aaf(f.root) self.assertEqual( len(f.content.mobs), len(prores_profiles) * 3, "Failed to create exactly three MOBs per prores_profile") self.assertEqual( len(list(f.content.mastermobs())), len(prores_profiles), "Failed to create exactly one MasterMOB per prores_profile") for mastermob_id in created_mastermob_ids: mastermob = next( (mob for mob in f.content.mobs if mob.mob_id == mastermob_id), None) self.assert_mastermob_valid_edit_spec(mastermob, expected_picture_slots=1, expected_sound_slots=2) self.assert_valid_multiple_descriptor(mastermob, 2)