use a variable name with VideoWriter

13 visualizaciones (últimos 30 días)
Bryan Clark
Bryan Clark el 9 de Abr. de 2018
Comentada: Walter Roberson el 10 de Abr. de 2018
I am trying to create a program to create videos from images. I would like to use inputdlg to create a variable file name. I can use a selected path. However, it doesn't appear that VideoWriter allows you to use a variable name. Is there a way around this?

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Abr. de 2018
VideoWriter has no problems with variable file names.
[filename, pathname] = uiputfile('*.avi', 'Select an output file');
if ~ischar(filename); return; end %user cancel
fullname = fullfile(pathname, filename);
obj = VideoWriter(fullname);
...

Más respuestas (1)

Bryan Clark
Bryan Clark el 10 de Abr. de 2018
Editada: Walter Roberson el 10 de Abr. de 2018
fileName = inputdlg('Input File Name');
fileName = strcat(fileName,'.avi');
if ~ischar(fileName);
a = 'not char'
disp(a)
end
my problem is that the inputdlg doesn't seem to create a chr variable even though is seems to be. Is there a way to make inputdlg return a chr array?
  1 comentario
Walter Roberson
Walter Roberson el 10 de Abr. de 2018
response = inputdlg('Input File Name');
fileName = response{1};
if isempty(fileName); return; end %user cancel
[dirname, basename, ext] = fileparts(fileName);
if isempty(ext); ext = '.avi'; end
fileName = fullfile(dirname, [basename ext]);

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by