How to use the moviepy.video.io.bindings.PIL_to_npimage function in moviepy

To help you get started, we’ve selected a few moviepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SenorPez / project-cars-replay-enhancer / replay.py View on Github external
video = black_test(g.sourcevideo)
	video_width, video_height = video.size

	if g.backdrop != "":
		backdrop = Image.open(g.backdrop).resize((video_width, video_height))
		if g.logo != "":
			logo = Image.open(g.logo).resize((g.logo_width, g.logo_height))
			backdrop.paste(logo, (backdrop.width-logo.width, backdrop.height-logo.height), logo)
	else:
		backdrop = Image.new('RGBA', (video_width, video_height), (0, 0, 0))
		if g.logo != "":
			logo = Image.open(g.logo).resize((g.logo_width, g.logo_height))
			backdrop.paste(logo, (backdrop.width-logo.width, backdrop.height-logo.height), logo)
			
	backdrop = mpy.ImageClip(PIL_to_npimage(backdrop))
	#title = mpy.ImageClip(make_title()).set_duration(6).set_position(('center', 'center'))
	title = mpy.ImageClip(SeriesStandings().to_frame()).set_duration(6).set_position(('center', 'center'))

	standing = UpdatedVideoClip(Standings(0))
	standing = standing.set_position((g.margin, g.margin)).set_duration(video.duration)
	standing_mask = mpy.ImageClip(Standings(0).make_mask(), ismask=True, duration=video.duration)
	standing = standing.set_mask(standing_mask)

	timer = UpdatedVideoClip(Timer(0))
	timer_width, timer_height = timer.size
	timer = timer.set_position((video_width-timer_width-g.margin, g.margin)).set_duration(video.duration)
	timer_mask = mpy.ImageClip(Timer(0).make_mask(), ismask=True, duration=video.duration)
	timer = timer.set_mask(timer_mask)

	result = mpy.ImageClip(make_results()).set_duration(20).set_position(('center', 'center'))
	result.mask = result.mask.fx(vfx.fadeout, 1)
github SenorPez / project-cars-replay-enhancer / make_title.py View on Github external
def make_title_mask():
	material, *rest = title_data()
	return PIL_to_npimage(material.split()[-1].convert('RGB'))
github SenorPez / project-cars-replay-enhancer / make_standings.py View on Github external
def make_mask(t):
	return PIL_to_npimage(make_material(t, bgOnly=True).split()[-1].convert('RGB'))
github SenorPez / project-cars-replay-enhancer / make_series_standings.py View on Github external
def make_series_standings_mask():
	material, *rest = series_data()
	return PIL_to_npimage(material.split()[-1].convert('RGB'))
github SenorPez / project-cars-replay-enhancer / replayenhancer / DynamicBase.py View on Github external
def to_frame(self):
        """Render the card with data. Override to customize."""
        return PIL_to_npimage(
            self._make_material(False).convert('RGB'))
github SenorPez / project-cars-replay-enhancer / make_title.py View on Github external
yPos += g.headingfont.getsize(g.headingtext)[1]

	draw.text((20, yPos), g.subheadingtext, fill='white', font=g.font)
	yPos += g.font.getsize(g.subheadingtext)[1]+g.margin
	yPos += g.margin/2

	columnPositions = [g.margin if i == 0 else g.margin+g.columnMargin*i+sum(columnWidths[0:i]) if columnWidths[i-1] != 0 else g.margin+g.columnMargin*(i-1)+sum(columnWidths[0:(i-1)]) for i, w in enumerate(columnWidths)]

	for i, n, t, c in [list(zip(x, columnPositions)) for x in startingGridData[:16]]:
		draw.text((i[1], yPos), str(i[0]), fill='black', font=g.font)
		draw.text((n[1], yPos), str(n[0]), fill='black', font=g.font)
		draw.text((t[1], yPos), str(t[0]), fill='black', font=g.font)
		draw.text((c[1], yPos), str(c[0]), fill='black', font=g.font)
		yPos += dataHeight+g.margin

	return PIL_to_npimage(material)
github SenorPez / project-cars-replay-enhancer / make_series_standings.py View on Github external
yPos += g.headingfont.getsize(g.headingtext)[1]

	draw.text((20, yPos), g.subheadingtext, fill='white', font=g.font)
	yPos += g.font.getsize(g.subheadingtext)[1]+int(g.margin*1.5)

	columnPositions = [g.margin if i == 0 else g.margin+g.columnMargin*i+sum(columnWidths[0:i]) if columnWidths[i-1] != 0 else g.margin+g.columnMargin*(i-1)+sum(columnWidths[0:(i-1)]) for i, w in enumerate(columnWidths)]

	for r, n, t, c, pts in [list(zip(x, columnPositions)) for x in standings]:
		draw.text((r[1], yPos), str(r[0]), fill='black', font=g.font)
		draw.text((n[1], yPos), str(n[0]), fill='black', font=g.font)
		draw.text((t[1], yPos), str(t[0]), fill='black', font=g.font)
		draw.text((c[1], yPos), str(c[0]), fill='black', font=g.font)
		draw.text((pts[1]+(columnWidths[4]-g.font.getsize(str(pts[0]))[0])/2, yPos), str(pts[0]), fill='black', font=g.font)
		yPos += dataHeight+g.margin

	return PIL_to_npimage(material)
github SenorPez / project-cars-replay-enhancer / replayenhancer / GTStandings.py View on Github external
def to_frame(self):
        return PIL_to_npimage(self._make_material().convert('RGBA'))
github SenorPez / project-cars-replay-enhancer / replayenhancer / replayenhancer.py View on Github external
def timecode_frame(time):
            """
            Custom make frame for timecode.
            """
            timecode_image = Image.new('RGB', (100, 40))
            draw = ImageDraw.Draw(timecode_image)
            draw.text((10, 10), "%.02f" % time)
            return PIL_to_npimage(timecode_image)