segmentation fault 11 when attempting to convert numpy ndarray to .avi video using PyAV module

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



segmentation fault 11 when attempting to convert numpy ndarray to .avi video using PyAV module



I receive a Segmentation fault 11 error when trying to convert numpy arrays to a video file. I am using the PyAV module, whose documentation can be found at http://mikeboers.github.io/PyAV/



the line


frame = av.VideoFrame.from_ndarray(image)



converts the 512 x 512 numpy array successfully into the frame object defined in PyAV. It is the next line which causes the segmentation fault


for packet in stream.encode(frame):
container.mux(packet)



Would someone be able to direct me towards what might be causing the segmentation fault in this line? I have checked through the issues raised on the PyAV homepage, but I can't find anything which looks similar.



My Script to convert a numpy nd array into an avi video


import tifffile as tf
import sys
import av
from skimage.color import gray2rgb


sys.path.append('/Users/MarcusF/PyAV')?



#Here I import a ImageJ compatible hyper stack into a 1900 x 512 x 512 numpy array


with tf.TiffFile('/Users/MarcusF/Desktop/260522_CecB- PCPG vesicles- after
flushing_1_MMStack_Pos6.ome.tif') as tif:
images = tif.asarray()



#These images have binned pixels, i believe they are stored as uint16 type not uint8 i try to change this


images = images/np.max(images)
images = images *255
images = images.astype('uint8')



** At this point use of the av module starts **


fps = 30


container = av.open('/Users/MarcusF/Desktop/OLA2.avi','w')
stream = container.add_stream('mpeg4', rate=fps)
stream.width = images.shape[2]
stream.height = images.shape[1]
stream.pix_fmt = 'yuv420p'


for image in images:
frame = av.VideoFrame.from_ndarray(image)

for packet in stream.encode(frame):
container.mux(packet)



^^^^^^AT THIS POINT the kernel dies when running in Jupyter notebooks. I tried running in python from the mac terminal and python quits and i receive a notification of SEGMENTATION FAULT 11



remainder of script, error occurs before this runs I believe


for packet in stream.encode():
container.mux(packet)

#Close the file
container.close()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard