videoCopyFrames

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Video/Audio/PDF
Introduced first in SolidGeometry 3.2, Creation date: 2016-12-28, Last change: 2025-09-14

copies the frame from Videoreader to Videowriter

Description

If the format of the videoreader is not the same as the format of the videowriter, the frames are scaled by using imresize.

See Also: imageVideoFrames , imageVideoTitle , imageVideoTextPage , imageVideoEndtitle , imageVideoWrite , videoCopyCutMovies

Example Illustration

 missing image of videoCopyFrames(v,vr)

Syntax

videoCopyFrames(v,vr)

Input Parameter

v: videoWriter
vr: videoReader

Examples


Wname=[desktopdir 'EXP_2020_03_11'];
Rname=tryuigetfile('','')
vr=VideoReader(Rname);
vw=VideoWriter(Wname); open(vw);
videoCopyFrames(vw,vr);
close (vw)




Copyright 2016-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm is designed to copy frames from a video reader object to a video writer object, potentially resizing the frames if the dimensions of the input and output videos differ.

Input Parameters

Algorithm Steps

  1. Initialize a variable nx to 0. This will be used to track the progress percentage.
  2. Retrieve the dimensions (height and width) of the input video using get(vr,'Height') and get(vr,'Width'), storing them in xyr.
  3. Retrieve the dimensions of the output video using get(v,'Height') and get(v,'Width'), storing them in xyw.
  4. If the output video dimensions xyw are empty, set them equal to the input video dimensions xyr.
  5. Enter a loop that continues as long as the current time of the video reader get(vr,'CurrentTime') is less than the total duration get(vr,'Duration').
  6. Within the loop, read the next frame from the video reader using readFrame(vr) and store it in I.
  7. If the dimensions of the input and output videos are not equal (~isequal(xyr,xyw)), resize the frame I to match the output dimensions using imresize(I,xyw).
  8. Write the (possibly resized) frame I to the video writer using writeVideo(v,I).
  9. Calculate the progress percentage n as 100 times the rounded division of the current time over the total duration, rounded to the nearest 5%.
  10. If the current progress percentage n is not equal to the last recorded percentage nx, print the percentage to the console and update nx to n.
Algorithm explaination created using ChatGPT on 2025-08-19 00:33. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21