How to replace a frame (rgb image) in a small video sequence ?
3 ビュー (過去 30 日間)
古いコメントを表示
I want to replace a single rgb frame in a 4 sec video sequence, example i want to replace the 5th frame with my rgb image of same dimension as the video dimension (example 256x256)
0 件のコメント
採用された回答
Walter Roberson
2017 年 2 月 13 日
vid = 'NameOfTheVideo.avi';
obj = VideoReader(vid);
newobj = VideoWriter('NameOfNewVideo.avi', 'Uncompressed AVI');
replacement_frame_5 = randi([0 255], 256, 256, 3, 'uint8'); %or as appropriate
fr = 0;
while hasFrame(obj)
fr = fr + 1;
a = readFrame(obj);
if fr == 5
a = replacement_frame_5;
end
writeVideo(newobj, a);
end
close(newobj);
clear obj
2 件のコメント
Walter Roberson
2018 年 4 月 21 日
編集済み: Walter Roberson
2018 年 4 月 21 日
It is not possible to play a video writer object. Once the video writer object is closed, use one of the techniques to play the video by name. Or create a video player object and step(player, a) as you go through outputting the frames to the video writer object.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!