I want to pass my customOutput class to raspberry pi camera function and want to enncode that output to mp4 and save it.
class MyOutput(object):
def __init__(self):
self.size = 0
def write(self, s):
#get h264 encoded frames?
#decode and encode them to mp4?
#append to the file?
self.size += len(s)
def flush(self):
print('%d bytes would have been written' % self.size)
class RecordVideo:
def __init__(self):
self.camera = PiCamera()
def startRecording(self, filename, source, recordingTime, format='h264'):
self.camera.start_recording(MyOutput(), format)
self.camera.wait_recording(recordingTime)
self.camera.stop_recording()
if __name__ == "__main__":
aat = RecordVideo()
for i in range(10):
aat.startRecording('testvideo_'+str(i)+'.h264', './', 10, 'h264')
aat.stopRecording()
Since piCamera plugin doesnt support mp4 encoding out of the box is there a way i can use any plugin and accomplish creating 10 mp4 files.
Any help will be appreciated.
Thanks