I found a discussion here (I didn't try it). It's probably possible to use template=in_stream when re-encoding, but we have to set the time-base, and set the PTS timestamp of each encoded packet. Using add_stream(template=in_stream) is only documented in the Remuxing example. Is there a way to modify the dts value, or possibly another method to create a video from a set of PIL.Image objects? Overwriting the pts value of the new frame with the original values still causes the same error, and overwriting the dts value of the new frame gives the following error: AttributeError: attribute 'dts' of 'av.frame.Frame' objects is not writable I followed the answer given in How to create a video out of frames without saving it to disk using python?, and met with the same issue.Ĭomparing the original VideoFrame and the VideoFrame created from the image, I found that the pts value of the new frames are saved as None instead of integer values. > 11 out_packet = out_stream.encode(out_frame)įile av\stream.pyx:153, in av.()įile av\codec\context.pyx:490, in av.()įile av\frame.pyx:52, in av.frame.Frame._rebase_time() ValueError Traceback (most recent call last)ġ0 out_frame = av.om_image(img_frame) Out_packet = out_stream.encode(out_frame)Īnd the error that I got:. # Some possible modifications to img_frame. Out_stream = test_output.add_stream(template=in_stream)įor frame in test_code(in_stream): Test_output =av.open('output_vid.mp4', 'w') What I have tried: def modify_image(img): The frames will be given in PIL.Image format and is often cropped to include only a part of the input video, but all images will have the same dimension. I am trying to write a function that creates a new MP4 video from a set of frames taken from another video.
0 Comments
Leave a Reply. |