how to merge 2 videos into 1 video without losing FPS?
Ältere Kommentare anzeigen
Hi,
I have 2 x 10 mins videos, both with the 59.94 FPS. Since the videos holding the same experimental phenomena in 2 videos. I want to merge them two videos without losing any frame, (I achieve this by using the window 10 but losing my frame rate means losing data). I also have tried the code below but what this code is doing putting both videos side by side this is not what I am after. I am looking to merge 2 videos into 1. If anyone can help that be great!
Code:
close all; clear all; clc;
vid1 = VideoReader('test.avi');
vid2 = VideoReader('test1.avi');
videoPlayer = vision.VideoPlayer;
% new video
outputVideo = VideoWriter('finaltest.avi');
outputVideo.FrameRate = vid1.FrameRate;
open(outputVideo);
img1 = readFrame(vid1);
[rows1, columns1, numColors1] = size(img1);
img2 = readFrame(vid2);
[rows2, columns2, numColors2] = size(img1);
img2 = imresize(img2, [rows1, rows2]);
imgt = horzcat(img1, img2);
while hasFrame(vid1) && hasFrame(vid2)
img1 = readFrame(vid1);
[rows1, columns1, numColors1] = size(img1);
img2 = readFrame(vid2);
[rows2, columns2, numColors2] = size(img1);
img2 = imresize(img2, [rows1, rows2]);
imgt = horzcat(img1, img2);
% play video
step(videoPlayer, imgt);
% record new video
writeVideo(outputVideo, imgt);
end
release(videoPlayer);
close(outputVideo);
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Audio I/O and Waveform Generation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
