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
- v: A videoWriter object that specifies the output video file where frames will be written.
- vr: A videoReader object that specifies the input video file from which frames will be read.
Algorithm Steps
- Initialize a variable
nx
to 0. This will be used to track the progress percentage.
- Retrieve the dimensions (height and width) of the input video using
get(vr,'Height')
and get(vr,'Width')
, storing them in xyr
.
- Retrieve the dimensions of the output video using
get(v,'Height')
and get(v,'Width')
, storing them in xyw
.
- If the output video dimensions
xyw
are empty, set them equal to the input video dimensions xyr
.
- 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')
.
- Within the loop, read the next frame from the video reader using
readFrame(vr)
and store it in I
.
- 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)
.
- Write the (possibly resized) frame
I
to the video writer using writeVideo(v,I)
.
- Calculate the progress percentage
n
as 100 times the rounded division of the current time over the total duration, rounded to the nearest 5%.
- 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