I keep trying to convert a video grayscale but it gives me an error?
Mostra commenti meno recenti
hi, i want to convert a video into grayscale, but it keeps giving me an error, specifically a "parse_input" error
my code:
%Create a multimedia reader video
readerobj = VideoReader('yourvideo.mp4', 'tag', 'myreader1');
readerobj.Width
readerobj.Height
% Read in all video frames.
vidFrames = read(readerobj);
% Get the number of frames.
numFrames = get(readerobj, 'NumberOfFrames');
%creat an output video file
v = VideoWriter('peaks.avi');
%Set the output video framerate to the input frame rate
v.FrameRate = readerobj.FrameRate;
open(v);
% Create a MATLAB movie struct from the video frames.
for k = 1 : numFrames
%get a frame from the video
frame=vidFrames(:,:,:,k);
frame = rgb2gray(frame);
%write the frame to the output video file
writeVideo(v,frame);
%add the frame to a movie object
mov(k).cdata = frame;
mov(k).colormap = [];
%if you want to save the frame
%Create Filename to store
end
%close the output video file. This will finish writing he video file
close(v);
% Create a figure
hf = figure;
% Resize figure based on the video's width and height
set(hf, 'position', [150 150 readerobj.Width readerobj.Height])
% Playback movie once at the video's frame rate
movie(hf, mov, 1, readerobj.FrameRate);
2 Commenti
Ameer Hamza
il 25 Apr 2020
What is the error message? How is vidFrames calculated?
Ahmed Al-Qarqaz
il 25 Apr 2020
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Video Formats and Interfaces in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!