Resize video#
Use the Frames.resize() method, which takes a tuple with the desired
size as an argument. Let’s resize to (640,360).
.. code:: python
>>> import birdwatcher as bw
>>> vfs = bw.VideoFileStream('myvideo.mp4')
>>> (vfs.iter_frames()
... .resize((640,360))
... .tovideo('myvideo_resized', framerate=vfs.avgframerate))
Alternatively you can resize by specifying a factor, e.g. 0.5, using the
Frames.resizebyfactor() method.
Much of the functionality in terms of video transformations is accessible
through Frames objects, which yield video frames. A Frames
object can be obtained from a VideoFileStream object using the
VideoFileStream.iter_frames() method. Frames objects have many
interesting methods,among which Frames.resize(), which yields another
Frames object, with resized frames. Frames objects can be used for analyses,
but they can also be written as a video file using their Frames.tovideo()
method.
More explanation on Frames is provided in our tutorial notebook 1_videoframes