Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

update video write class #1

@walchko

Description

@walchko
class SaveVideo(object):
	"""
	Simple class to save frames to video (mp4v)

	macOS: avc1
	windows: h264?
	"""

	def __init__(self):
		self.out = None
		self.encoder('avc1')  # default mac

	def open(self, filename, width, height, fps=30):
                """Note, width/height is backwards from opencv"""
		self.out = cv2.VideoWriter()
		self.out.open(filename, self.mpg4, fps, (width,height))

	def encoder(self, fourcc):
                """Change the encoder, fourcc params are located:
                https://www.fourcc.org/codecs.php
                """
		self.mpg4 = cv2.VideoWriter_fourcc(*fourcc)

	def __del__(self):
		self.release()

	def write(self, image):
		self.out.write(image)

	def release(self):
		if self.out:
			self.out.release()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions