-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcutVideo.m
56 lines (40 loc) · 1.21 KB
/
cutVideo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
clear all;
close all;
clc;
base_path = '../data_input/Videos_Ori';
save_path = '../data_output/6_Videos';
if ~exist(save_path, 'dir')
mkdir(save_path)
end
id_list = dir(fullfile(base_path,'*.mp4'));
id_exist = dir(fullfile(save_path,'*.mp4'));
fileids_exist = string(missing);
for idx = 1 : length(id_exist)
% load
fileids_exist(idx) = id_list(idx).name;
end
for idx = 1 : length(id_list)
% load
if ~isempty(intersect(id_list(idx).name, fileids_exist))
fprintf([id_list(idx).name, ' exist\n']);
continue
end
video_read_name = fullfile(base_path, id_list(idx).name);
v = VideoReader(video_read_name);
% save
video_save_name = fullfile(save_path, [id_list(idx).name(1:11), '.mp4']);
v_save = VideoWriter(video_save_name);
open(v_save);
fprintf(['\n', id_list(idx).name]);
cnt = 1;
while hasFrame(v)
cnt_str = sprintf('%03d',cnt);
fprintf([cnt_str,'/400...'])
frame = readFrame(v);
len = length(frame);
writeVideo(v_save,frame(:,1:len/2,:))
fprintf('\b\b\b\b\b\b\b\b\b\b')
cnt = cnt + 1;
end
close(v_save);
end