Skip to content

Commit 7d2337b

Browse files
FedericaFederica
authored andcommitted
Added video related functions + demo
1 parent b9d8bb7 commit 7d2337b

33 files changed

+112
-0
lines changed

demos/CPP_playVideoFramesDemo.m

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
% (C) Copyright 2021 CPP_PTB developers
2+
3+
%% Demo showing how to use the createFramesTextureStructure and playVideoFrames functions
4+
5+
% This small script shows how to use the getReponse function
6+
7+
% add parent directory to matlab path (so we can access the CPP_PTB functions)
8+
addpath(fullfile(pwd, '..'));
9+
10+
%% start with a clean slate
11+
clear;
12+
clc;
13+
14+
% use the default set up (use main keyboard and use the ESCAPE key to abort)
15+
16+
17+
%% initialize PTB % This can def be improved by using other CPP_PTB functions%
18+
19+
% Skip the PTB sync test
20+
Screen('Preference', 'SkipSyncTests', 2);
21+
22+
% Get the screen numbers and draw to the external screen if avaliable
23+
cfg.screen.idx = max(Screen('Screens'));
24+
25+
% Set the PTB window background manually
26+
cfg.color.background = [127 127 127];
27+
28+
% Get the screen numbers and draw to the external screen if avaliable
29+
cfg.screen.idx = max(Screen('Screens'));
30+
31+
% Open an on screen window
32+
[cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background);
33+
34+
35+
%% Video related info
36+
37+
% The name of your "video" and its images format
38+
cfg.video.name = 'coffee';
39+
40+
% The format fo the images
41+
cfg.video.frame.format = '.jpeg'; % can be any img format compatible with the "imread" function
42+
43+
% the folder where the images are (from the current folder)
44+
cfg.video.path = '/video_frames/';
45+
46+
% The frame rate at which you want to present your video
47+
cfg.video.frame.rate = 29.97;
48+
49+
% The number of frames of your video you want to present
50+
cfg.video.frame.number = 30;
51+
52+
53+
% Read the images and create the stucture with their textures
54+
cfg = createFramesTextureStructure(cfg);
55+
56+
57+
% Play the video
58+
playVideoFrames(cfg);
59+
60+
61+
% The end
62+
sca;

demos/video_frames/coffee1.jpeg

14 KB
Loading

demos/video_frames/coffee10.jpeg

14.2 KB
Loading

demos/video_frames/coffee11.jpeg

14.2 KB
Loading

demos/video_frames/coffee12.jpeg

14.3 KB
Loading

demos/video_frames/coffee13.jpeg

14.3 KB
Loading

demos/video_frames/coffee14.jpeg

14.3 KB
Loading

demos/video_frames/coffee15.jpeg

14.3 KB
Loading

demos/video_frames/coffee16.jpeg

14.3 KB
Loading

demos/video_frames/coffee17.jpeg

14.4 KB
Loading

0 commit comments

Comments
 (0)