Пример #1
0
    def test_24fps(self):
        p = Parser('24')
        with open('../tests/test_data/test_24.edl') as f:
            s = p.parse(f)

        self.assertEqual(s.events[0].clip_name, 'clip 1',
                         'Failed clip name test')
        self.assertEqual(s.events[0].src_length(), 1440,
                         'Wrong source frame length')
        self.assertEqual(s.events[0].rec_length(), 1440,
                         'Wrong record frame length')
        self.assertEqual(s.events[0].src_end_tc.frame_number, 87840,
                         'Wrong source end timecode')
        self.assertEqual(s.events[0].rec_start_tc.frame_number, 0,
                         'Wrong record start timecode')
        self.assertEqual(s.events[0].rec_end_tc.frame_number, 1440,
                         'Wrong record end timecode')
        self.assertEqual(s.events[1].clip_name, 'clip #2',
                         'Failed clip name test char 2')
        self.assertEqual(s.events[2].clip_name, 'clip -3',
                         'Failed clip name test char 3')
        self.assertEqual(s.events[3].clip_name, 'clip $4',
                         'Failed clip name test char 4')
        self.assertEqual(s.events[4].clip_name, 'clip &5',
                         'Failed clip name test char 5')
        self.assertEqual(s.events[5].src_start_tc.frame_number, 697,
                         "Wrong Source start complex event")
        self.assertEqual(s.events[5].src_end_tc.frame_number, 697,
                         "Wrong Source end complex event")
        self.assertEqual(s.events[5].rec_start_tc.frame_number, 2857,
                         "Wrong Source start complex event")
        self.assertEqual(s.events[5].rec_end_tc.frame_number, 2857,
                         "Wrong Source end complex event")
Пример #2
0
	def handleEDLImport(self):
		file = nuke.getFilename('Import EDL', pattern='*.edl')
		fps = self.ui.CMB_fps.currentText()
		parser = Parser(fps)

		if not file or not os.path.exists(file) or os.path.isdir(file):
			return

		with open(file) as f:
			edl = parser.parse(f)

			for event in edl.events:
				start, end = event.src_start_tc.frame_number, event.src_end_tc.frame_number
				clip = event.reel
				eventFootage = None

				for root, dirnames, filenames in os.walk(self.baseDir):
					for filename in fnmatch.filter(filenames, clip + '.*'):
						eventFootage = os.path.join(root, filename)

				if not eventFootage:
					nuke.message('Unable to find matching footage in specified base directory (or any of its children), aborting.')
					return

				self.handleFootageImport(files=[eventFootage])

				shots = self.shotConfig.get(eventFootage, [])
				_, frameOffset = self.reads.get(eventFootage, (None, 0))

				shots.append(ShotListItemWidget(int(event.num) * 100, startFrame=start-frameOffset, endFrame=end-frameOffset)) # TODO configuration for shot number padding

				self.shotConfig[eventFootage] = shots
Пример #3
0
def parse_edl(edl_path, fps):
    """Parse EDL and return list  with EDL Events.

    Args:
        edl_path (str): Absoulte path to EDL.
        fps (float): Frame Rate for EDL calculations.

    Returns:
        Edl: EDL instance.

    """
    edl = None
    parser = Parser(fps)
    # Clear members, so the ids are empty and no unique ids are created.
    correction.ColorCorrection.members = {}
    if os.path.isfile(edl_path):
        with open(edl_path) as edl_file:
            edl = parser.parse(edl_file)
            for event in edl.events:
                event.cdl = correction.ColorCorrection(event.reel)
                event.has_locator = False
                if event.comments:
                    for comment in event.comments:
                        if "ASC_SOP" in comment:
                            add_sop(event.cdl, comment)
                        if "ASC_SAT" in comment:
                            add_sat(event.cdl, comment)
                        if "LOC: " in comment:
                            add_avid_locator(event, comment)
    return edl
Пример #4
0
 def read_avid_edl(self, avid_eld_path, fps='24'):
     """
     """
     self.fps = fps
     p = Parser(fps)
     with open(avid_eld_path) as f:
         self.events = p.parse(f)
Пример #5
0
    def test_24fps(self):
        p = Parser('24')
        with open('tests/test_data/test_24.edl') as f:
            s = p.parse(f)

        self.assertEqual(s.events[0].clip_name, 'clip 1',
                         'Failed clip name test')
        self.assertEqual(s.events[0].src_length(), 1440,
                         'Wrong source frame length')
        self.assertEqual(s.events[0].rec_length(), 1440,
                         'Wrong record frame length')
        self.assertEqual(s.events[0].src_end_tc.frame_number, 87840,
                         'Wrong source end timecode')
        self.assertEqual(s.events[0].rec_start_tc.frame_number, 0,
                         'Wrong record start timecode')
        self.assertEqual(s.events[0].rec_end_tc.frame_number, 1440,
                         'Wrong record end timecode')
        self.assertEqual(s.events[1].clip_name, 'clip #2',
                         'Failed clip name test char 2')
        self.assertEqual(s.events[2].clip_name, 'clip -3',
                         'Failed clip name test char 3')
        self.assertEqual(s.events[3].clip_name, 'clip $4',
                         'Failed clip name test char 4')
        self.assertEqual(s.events[4].clip_name, 'clip &5',
                         'Failed clip name test char 5')
        self.assertEqual(s.events[5].src_start_tc.frame_number, 697,
                         "Wrong Source start complex event")
        self.assertEqual(s.events[5].src_end_tc.frame_number, 697,
                         "Wrong Source end complex event")
        self.assertEqual(s.events[5].rec_start_tc.frame_number, 2857,
                         "Wrong Source start complex event")
        self.assertEqual(s.events[5].rec_end_tc.frame_number, 2857,
                         "Wrong Source end complex event")
Пример #6
0
    def testing_to_edl_method_will_output_the_standard_edl_case1(self):
        """testing if to_string will output the EDL as string
        """
        p = Parser('24')
        with open('tests/test_data/test_24.edl') as f:
            expected_edl = [line.rstrip('\n') for line in f.readlines()]
            # Reset to beginning of file and read into new EDL
            f.seek(0)
            actual_edl = p.parse(f).to_string().split('\n')

        # Remove blank lines, since they don't affect data content
        expected_edl = [line for line in expected_edl if line]
        actual_edl = [line for line in actual_edl if line]

        # self.maxDiff = None
        # print expected_edl
        print actual_edl
        print len(actual_edl),len(expected_edl)
        self.assertEqual(len(expected_edl), len(actual_edl),"Generated EDL has the same"
            "number of data lines as original EDL.")

        for expected, actual in izip_longest(expected_edl, actual_edl):
            # Remove extraneous whitespace to prevent false negatives
            expected = " ".join(expected.split())
            actual = " ".join(actual.split())
Пример #7
0
    def testing_to_edl_method_will_output_the_standard_edl_case1(self):
        """testing if to_string will output the EDL as string
        """
        p = Parser('24')
        with open('tests/test_data/test_24.edl') as f:
            expected_edl = [line.rstrip('\n') for line in f.readlines()]
            # Reset to beginning of file and read into new EDL
            f.seek(0)
            actual_edl = p.parse(f).to_string().split('\n')

        # Remove blank lines, since they don't affect data content
        expected_edl = [line for line in expected_edl if line]
        actual_edl = [line for line in actual_edl if line]

        # self.maxDiff = None
        # print expected_edl
        print actual_edl
        print len(actual_edl), len(expected_edl)
        self.assertEqual(
            len(expected_edl), len(actual_edl), "Generated EDL has the same"
            "number of data lines as original EDL.")

        for expected, actual in izip_longest(expected_edl, actual_edl):
            # Remove extraneous whitespace to prevent false negatives
            expected = " ".join(expected.split())
            actual = " ".join(actual.split())
Пример #8
0
 def read_avid_edl(self, avid_eld_path, fps='24'):
     """
     """
     self.fps = fps
     p = Parser(fps)
     with open(avid_eld_path) as f:
         self.events = p.parse(f)
Пример #9
0
    def testing_to_edl_method_will_output_the_standard_edl_case3(self):
        """testing if to_string will output the EDL as string
        """
        p = Parser('24')
        with open('tests/test_data/test_50.edl') as f:
            s = p.parse(f)

        with open('tests/test_data/test_50.edl') as f:
            expected_edl = f.readlines()

        print s.to_string()

        self.assertEqual(''.join(expected_edl), s.to_string())
Пример #10
0
    def testing_to_edl_method_will_output_the_standard_edl_case3(self):
        """testing if to_string will output the EDL as string
        """
        p = Parser('24')
        with open('tests/test_data/test_50.edl') as f:
            s = p.parse(f)

        with open('tests/test_data/test_50.edl') as f:
            expected_edl = f.readlines()

        print s.to_string()

        self.assertEqual(
            ''.join(expected_edl),
            s.to_string()
        )
Пример #11
0
def main():
    '''
    Filters tracks in EDL according to passed argument (A by default)
    and writes to a new EDL file.
    '''

    # Parsing command line arguments.
    parser = argparse.ArgumentParser(description='''
            Filter tracks in EDL.
        ''')
    parser.add_argument('source',
                        type=argparse.FileType(mode='r'),
                        help='source EDL file')
    parser.add_argument('-t',
                        '--tracks',
                        type=str,
                        help='tracks to filter',
                        default='A')
    parser.add_argument('-f',
                        '--fps',
                        type=str,
                        help='EDL frame rate',
                        default='24')
    args = parser.parse_args()

    # tracks name pattern to filter
    pattern = args.tracks
    # create edl parser with corresponding frame rate
    print(f'Working in {args.fps}fps')
    parser = Parser(args.fps)

    # read EDL file
    edl = parser.parse(args.source)
    # filter events, with matching track name
    num_filtered = filter_tracks(edl, pattern)

    with open(outname(args.source.name), 'w') as output:
        output.write(edl.to_string())

    print(
        f'Filtered {num_filtered} events matching \'{pattern}\' in track name')
Пример #12
0
    def parser(self):
        events = []

        # Accepted framerates
        # 60, 59.94, 50, 30, 29.97, 25, 24, 23.98
        parser = Parser('59.94')

        with open(self.path) as f:
            edl = parser.parse(f)
            for event in edl.events:

                clip = {
                    "event_number": str(event.num),
                    "clip_name": str(event.clip_name),
                    "start": str(event.rec_start_tc),
                    "end": str(event.rec_end_tc)
                }

                events.append(clip)

        return events
Пример #13
0
#!/usr/env python
#coding:utf8

import os
from edl import Parser

edlfile = os.path.expanduser("~/examples/edl/lazypic_example.edl")
a = Parser("23.98")
with open(edlfile) as p:
    edl= a.parse(p)
    for event in edl.events:
        print "Event Number:" + str(event.num)
        print "Source file:" + str(event.source_file)
        print "Clip Name:" + str(event.clip_name)
		#print dir(event)
Пример #14
0
 def test_2398fps(self):
     p = Parser('23.98')
     with open('tests/test_data/test_2398.edl') as f:
         s = p.parse(f)
Пример #15
0
from email import encoders

from email.mime.image import MIMEImage
from email.mime.audio import MIMEAudio
from email import encoders

B_EXR_LIBRARY_EXISTS = False
if os.path.exists('/usr/local/lib/python2.7/site-packages/OpenEXR.so'):
    sys.path.insert(0, '/usr/local/lib/python2.7/site-packages')
    B_EXR_LIBRARY_EXISTS = True
    import OpenEXR


logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.info(str(sys.path))
parser=Parser('24')
edl_directory = r'/Volumes/romeo_primary/EDL_ALL'

version_names = []
all_edl_files = glob.glob(os.path.join(edl_directory, '*.edl'))
for edl_file in all_edl_files:
    logging.info('Examing EDL file at %s...'%edl_file)
    edl_base = os.path.basename(edl_file)
    with open(edl_file) as f:
        edl = parser.parse(f)
        for event in edl.events:
            if event.locator_name:
                logging.info('Found plate: %s'%event.locator_name)
                version_names.append([event.locator_name, edl_base])

plate_directory = r'/Volumes/romeo_primary/SHOTS/{sequence}/{shot}/img/plates'
Пример #16
0
 def test_2398fps(self):
     p = Parser('23.98')
     with open('../tests/test_data/test_2398.edl') as f:
         s = p.parse(f)
Пример #17
0
    def _parse_edl(self, edl_file_path):
        """
        :param edl_file_path: str
        :return:
        """
        if not self.first_time:
            self._delete_table_rows()
            self.edl_data = None
            self.element_list = list()
            self.output_file_name = None

        self.output_file_name = os.path.basename(edl_file_path)[:-4].replace(
            ' ', '_')

        master_list = list()
        element_list = list()

        parser = Parser(self.fps)

        with open(edl_file_path) as f:
            edl = parser.parse(f)
            for event in edl.events:
                event_dict = dict()
                event_dict['EDL Clip Name'] = str(event.reel)
                event_dict['Cut Duration'] = str(event.rec_length() + 1)
                event_dict['EDL Event Number'] = str(event.num)  # unused
                event_dict['EDL Timecode Start'] = str(event.src_start_tc)
                event_dict['EDL Timecode End'] = str(event.src_end_tc)
                event_dict['EDL REC Timecode Start'] = str(event.rec_start_tc)
                event_dict['EDL REC Timecode End'] = str(event.rec_end_tc)
                # parse nuke cc data
                nuke_cc = str()
                for comment in event.comments:
                    if comment.startswith('* ASC_SOP'):
                        nuke_cc += str(comment)
                    elif comment.startswith('* ASC_SAT'):
                        nuke_cc += ' ' + str(comment)
                if not nuke_cc:
                    nuke_cc = 'unavailable'
                event_dict['Nuke CC'] = nuke_cc
                event_dict['Entity Type'] = 'Element'  # default entity type
                event_dict['Parent Shots'] = ''
                # parse shot name
                m = self.rgx_clip_name.match(str(event.reel).strip())
                if m:
                    shot, element, extra = m.groups()
                    shot = str(shot.strip())
                    element = str(element.strip())
                    extra = str(extra.strip())
                    if element:
                        shot_code = shot + element + extra
                        event_dict['Parent Shots'] = shot
                    else:
                        shot_code = shot
                        event_dict['Entity Type'] = 'Shot'
                    event_dict['Shot Code'] = shot_code
                    event_dict['Episode'] = shot_code[0:1]
                    event_dict['Sequence'] = shot_code[0:3]
                # if the shot does not have a parent, it is a master plate
                if not event_dict['Parent Shots']:
                    master_list.append(event_dict)
                # otherwise, this is a shot element
                else:
                    element_list.append(event_dict)

        event_list = master_list + element_list

        if not event_list:
            msg = 'ERROR: no edl data'
            logger.info(msg)
            self.ui.label_status.setText(msg)
            return

        # create qt table
        self.edl_data = event_list
        self._create_table()

        msg = 'Hey {}, good work!'.format(self.user_first_name)
        self.ui.label_status.setText(msg)
Пример #18
0
 def test_ntsc(self):
     p = Parser('29.97')
     with open('tests/test_data/test_2997NDF.edl') as f:
         s = p.parse(f)
Пример #19
0
#!/usr/bin/env python
#coding:utf8

import os
from edl import Parser

edlfile = os.path.expanduser("~/examples/edl/lazypic_example.edl")
parser = Parser("23.98")
with open(edlfile) as f:
    edl = parser.parse(f)
    for event in edl.events:
        print "Event Number:" + str(event.num)
        print "Source file:" + str(event.source_file)
        print "Clip Name:" + str(event.clip_name)
        print dir(event)
Пример #20
0
    def test_from_edl_method_is_working_properly(self):
        """testing if the from_edl method will return an anima.previs.Sequence
        instance with proper hierarchy
        """
        # first supply an edl
        from edl import Parser
        p = Parser('24')
        edl_path = os.path.abspath('./test_data/test_v001.edl')

        with open(edl_path) as f:
            edl_list = p.parse(f)

        r = Rate(timebase='24')

        s = Sequence(rate=r)
        s.from_edl(edl_list)

        self.assertEqual('SEQ001_HSNI_003', s.name)

        self.assertEqual(111, s.duration)

        r = s.rate
        self.assertEqual('24', r.timebase)
        self.assertEqual('00:00:00:00', s.timecode)

        m = s.media
        self.assertTrue(isinstance(m, Media))

        v = m.video
        self.assertTrue(isinstance(v, Video))

        t = v.tracks[0]
        self.assertEqual(False, t.locked)
        self.assertEqual(True, t.enabled)

        clips = t.clips
        self.assertEqual(3, len(clips))

        clip1 = clips[0]
        clip2 = clips[1]
        clip3 = clips[2]

        self.assertTrue(isinstance(clip1, Clip))
        self.assertTrue(isinstance(clip2, Clip))
        self.assertTrue(isinstance(clip3, Clip))

        # clip1
        self.assertEqual(34, clip1.duration)
        self.assertEqual(True, clip1.enabled)
        self.assertEqual(35, clip1.end)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.id)
        self.assertEqual(10, clip1.in_)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.name)
        self.assertEqual(44, clip1.out)
        self.assertEqual(1, clip1.start)
        self.assertEqual('Video', clip1.type)

        f = clip1.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(44, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0010_v001.mov',
            f.pathurl
        )

        # clip2
        self.assertEqual(31, clip2.duration)
        self.assertEqual(True, clip2.enabled)
        self.assertEqual(66, clip2.end)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.id)
        self.assertEqual(10, clip2.in_)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.name)
        self.assertEqual(41, clip2.out)
        self.assertEqual(35, clip2.start)
        self.assertEqual('Video', clip2.type)

        f = clip2.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(41, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0020_v001.mov',
            f.pathurl
        )

        # clip3
        self.assertEqual(46, clip3.duration)
        self.assertEqual(True, clip3.enabled)
        self.assertEqual(112, clip3.end)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.id)
        self.assertEqual(10, clip3.in_)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.name)
        self.assertEqual(56, clip3.out)
        self.assertEqual(66, clip3.start)
        self.assertEqual('Video', clip3.type)

        f = clip3.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(56, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0030_v001.mov',
            f.pathurl
        )
Пример #21
0
 def test_pal(self):
     p = Parser('25')
     with open('tests/test_data/test_25.edl') as f:
         s = p.parse(f)
Пример #22
0
 def test_pal(self):
     p = Parser('25')
     with open('../tests/test_data/test_25.edl') as f:
         s = p.parse(f)
Пример #23
0
 def test_ntsc(self):
     p = Parser('29.97')
     with open('../tests/test_data/test_2997NDF.edl') as f:
         s = p.parse(f)
Пример #24
0
    def test_from_edl_method_is_working_properly_with_negative_timecodes(self):
        """testing if the from_edl method will return an anima.previs.Sequence
        instance with proper hierarchy event with clips that has negative
        timecode values (timecodes with in point is bigger than out point and
        around 23:59:59:XX as a result)
        """
        # first supply an edl
        from edl import Parser
        p = Parser('24')
        edl_path = os.path.abspath('./test_data/test_v003.edl')

        with open(edl_path) as f:
            edl_list = p.parse(f)

        r = Rate(timebase='24')

        s = Sequence(rate=r)
        s.from_edl(edl_list)

        self.assertEqual('SEQ001_HSNI_003', s.name)

        self.assertEqual(247, s.duration)
        self.assertEqual('24', s.rate.timebase)
        self.assertEqual('00:00:00:00', s.timecode)

        m = s.media
        self.assertTrue(isinstance(m, Media))

        v = m.video
        self.assertTrue(isinstance(v, Video))

        t = v.tracks[0]
        self.assertEqual(False, t.locked)
        self.assertEqual(True, t.enabled)

        clips = t.clips
        self.assertEqual(3, len(clips))

        clip1 = clips[0]
        clip2 = clips[1]
        clip3 = clips[2]

        self.assertTrue(isinstance(clip1, Clip))
        self.assertTrue(isinstance(clip2, Clip))
        self.assertTrue(isinstance(clip3, Clip))

        # clip1
        self.assertEqual(176, clip1.duration)
        self.assertEqual(True, clip1.enabled)
        self.assertEqual(153, clip1.end)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.id)
        self.assertEqual(15, clip1.in_)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.name)
        self.assertEqual(191, clip1.out)
        self.assertEqual(-23, clip1.start)
        self.assertEqual('Video', clip1.type)

        f = clip1.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(191, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0010_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0010_v001.mov',
            f.pathurl
        )

        # clip2
        self.assertEqual(55, clip2.duration)
        self.assertEqual(True, clip2.enabled)
        self.assertEqual(208, clip2.end)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.id)
        self.assertEqual(45, clip2.in_)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.name)
        self.assertEqual(100, clip2.out)
        self.assertEqual(153, clip2.start)
        self.assertEqual('Video', clip2.type)

        f = clip2.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(100, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0020_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0020_v001.mov',
            f.pathurl
        )

        # clip3
        self.assertEqual(1, clip3.duration)
        self.assertEqual(True, clip3.enabled)
        self.assertEqual(224, clip3.end)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.id)
        self.assertEqual(0, clip3.in_)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.name)
        self.assertEqual(1, clip3.out)
        self.assertEqual(208, clip3.start)
        self.assertEqual('Video', clip3.type)

        f = clip3.file
        self.assertTrue(isinstance(f, File))
        self.assertEqual(1, f.duration)
        self.assertEqual('SEQ001_HSNI_003_0030_v001', f.name)
        self.assertEqual(
            'file://localhost/tmp/SEQ001_HSNI_003_0030_v001.mov',
            f.pathurl
        )
Пример #25
0
#!/usr/env python
#coding:utf8
import os
from edl import Parser

home = os.path.expanduser("~")
parser = Parser('23.98')
with open(home + '/examples/edl/lazypic_example.edl') as f:
    edl = parser.parse(f)
    for event in edl.events:
        print "Event Number:" + str(event.num)
        print "Sourse file:" + str(event.source_file)
        print "Clip Name:" + str(event.clip_name)