필터 지우기
필터 지우기

Save a video from video frames and text

조회 수: 12 (최근 30일)
Alice
Alice 2016년 8월 19일
댓글: Alice 2016년 8월 24일
Hi everyone,
I have a video generated from an external software I want to insert dynamic text on each frame. I was able to do so in Matlab with the code below. However, I am clueless about the way to save the new video in a .mp4 or .avi file. I would like to have it in such format so that I can open it from any video readers.
Can anyone help?
Thank you! :-)
Alice
% Import video generated from an external software
v = VideoReader('video_L4_L8_Jan_cc25.mp4');
% Import csv file with metadata of each image
t = readtable('list_L4_L8_Jan_cc25.csv');
% Generate a video with the ID and time of acquisition of each image
figure
FrameRate = 1;
set(gcf,'units','centimeters');
set(gcf,'position',[10 10 30 30]);
axes1 = axes('position', [.05, .05, .9 , .9])
while hasFrame(v)
vFrames1 = readFrame(v);
imgNb = v.CurrentTime+1; % Nb of image displayed. +1 becaue CurrentTime starts couting at 0
image(vFrames1, 'Parent', axes1);
text(.5, 10, t.LANDSAT_SCENE_ID(imgNb), 'fontsize' , 14, 'Color' , 'w', 'Parent' , axes1);
text(200, 10, t.DATE_ACQUIRED(imgNb), 'fontsize' , 14, 'Color' , 'w', 'Parent' , axes1);
axes1.Visible = 'off';
pause(1/FrameRate);
end

채택된 답변

Dave Behera
Dave Behera 2016년 8월 23일
The writevideo function can be used to write videos from an array to video file (.avi format supported). See this link:
  댓글 수: 1
Alice
Alice 2016년 8월 24일
Yay, thanks! For anyone interested, this is the way to use the VideoWriter function and get the desired video as detailed in the initial question:
k = VideoWriter('videoName'); k.FrameRate = 2; open(k);
for i = 1: length(frame for video) CODE FOR VIDEO FRAME AND TEXT HERE
frame = getframe; writeVideo(k,frame); end
Close(k)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by