-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffmpeg_run_cmd.m
43 lines (31 loc) · 1.25 KB
/
ffmpeg_run_cmd.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
function [results] = ffmpeg_run_cmd(ffmpeg_cmd, show_feedback_bln)
% Run a validly formatted ffmpeg command in the system
if ~exist('show_feedback_bln', 'var'), show_feedback_bln = false; end;
%%
% if the command is already a string, run it
if ischar(ffmpeg_cmd)
% run command in system
[status, message] = system(ffmpeg_cmd);
% compile results
results.command = ffmpeg_cmd;
results.ok = ~status;
results.output = message;
% if failed, throw error
if ~results.ok
fprintf(results.output);
fprintf('\nffmpeg command:\n\t%s\n\n', ffmpeg_cmd);
clc error('ffmpeg command failed (see command and output above)');
end
% display feedback if requested
if show_feedback_bln
fprintf('ffmpeg command:\n\t%s\n%s\n', results.command, results.output);
end
% if the command is in structure format, convert to string and run it
elseif isstruct(ffmpeg_cmd)
ffmpeg_cmd2 = ffmpeg_build_cmd(ffmpeg_cmd);
ffmpeg_run_cmd(ffmpeg_cmd2, show_feedback_bln);
% unknown input
else
error('ffmpeg_cmd must be eithe a string or a structure');
end
end