Unicode_literals (from __future__) does not work with fourcc codec in openCV's VideoWriter()

Hey everyone,

I use:
Psychopy Version: 1.90.3
Python 2.7

I am trying to capture videofiles during my experiment using cv2’s VideoWriter().
The VideoWriter() function needs the fourcc codec as the second argument but it seems that the encoding via “cv2.VideoWriter_fourcc(*‘XVID’)” collides with the unicode_literals.
If unicode_literals is loaded, the error message pops up for the fourcc argument:

“TypeError: Expected signle character string for argument ‘c1’”

Here is my code snippet for the VideoRecording() function I want to call in my experiment source code. The error concerns the definition “fourcc = cv2.VideoWriter_fourcc(*‘XVID’)”

‘’’

def VideoRecording(video_width,video_height,video_fps,seconds):

cap = cv2.VideoCapture(0)
cap.set(3,video_width) # width
cap.set(4,video_height) #height 
cap.set(5,video_fps) # frames per second

# Define the codec and create VideoWriter object
fps = cap.get(5)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
filename = str('output_intrasync_video/' + subject[0] + '_' + str(trial_block) + '_' + str(x) + '.avi')
out = cv2.VideoWriter(filename,fourcc,video_fps, (video_width,video_height))

start = time.time()
zeitdauer=0
while(zeitdauer<seconds):
    end=time.time()
    zeitdauer=end-start
    ret, frame = cap.read()
    if ret==True:
        frame = cv2.flip(frame,180)
        # write the flipped frame
        out.write(frame)

        #cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

‘’’

Has anyone encountered the same problem? Or any ides why the fourcc codec is incompatible with unicode_literals?

Cheers,
Carrie