Skip to content

Commit

Permalink
add Video(..., scale=1) keyword in #1168
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Jul 28, 2024
1 parent a31b0a5 commit 241d51a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- fix `Arrow.top_index` to produce the correct index value
- add `assembly.Group.objects` by @smoothumut
- add `addons.DrawingWidget` class for tracing on planar props
- add `Video(..., scale=1)` keyword in #1168 by @YongcaiHuang


## Soft-breaking Changes
Expand Down
1 change: 0 additions & 1 deletion examples/other/make_video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Make a video file with or without graphic window"""
from vedo import dataurl, Plotter, Mesh, Video

# settings.screeshot_scale = 2 # to get higher resolution

msh = Mesh(dataurl+"spider.ply").rotate_x(-90)
msh.texture(dataurl+"textures/leather.jpg")
Expand Down
11 changes: 7 additions & 4 deletions vedo/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,18 +1907,20 @@ class Video:
Generate a video from a rendering window.
"""

def __init__(self, name="movie.mp4", duration=None, fps=24, backend="imageio"):
def __init__(self, name="movie.mp4", duration=None, fps=24, scale=1, backend="imageio"):
"""
Class to generate a video from the specified rendering window.
Program `ffmpeg` is used to create video from each generated frame.
Arguments:
name : (str)
name of the output file.
fps : (int)
set the number of frames per second.
duration : (float)
set the total `duration` of the video and recalculates `fps` accordingly.
fps : (int)
set the number of frames per second.
scale : (int)
set the image magnification as an integer multiplicative factor.
backend : (str)
the backend engine to be used `['imageio', 'ffmpeg', 'cv']`
Expand All @@ -1933,6 +1935,7 @@ def __init__(self, name="movie.mp4", duration=None, fps=24, backend="imageio"):
self.fps = float(fps)
self.command = "ffmpeg -loglevel panic -y -r"
self.options = "-b:v 8000k"
self.scale = scale

self.frames = []
self.tmp_dir = TemporaryDirectory()
Expand All @@ -1942,7 +1945,7 @@ def __init__(self, name="movie.mp4", duration=None, fps=24, backend="imageio"):
def add_frame(self) -> "Video":
"""Add frame to current video."""
fr = self.get_filename(str(len(self.frames)) + ".png")
screenshot(fr)
screenshot(fr, scale=self.scale)
self.frames.append(fr)
return self

Expand Down

0 comments on commit 241d51a

Please sign in to comment.