No data written to file in Matlab when using writeVideo (Ubuntu) - matlab

I am attempting to create a movie file from ascii data using Matlab. I am running Matlab on Ubuntu 13.10. When I run my Matlab script (see below), the frames display correctly and the .avi video file is created at the end, but there is no data in the file.
clc
clear all
writerObj=VideoWriter('testVideo');
writerObj.FrameRate = 10;
open(writerObj);
for i=1:15000
j=i*100;
str=[num2str(j),'_Temp1.dat'];
t=importdata(str);
showaxes;
colorbar;
imagesc(t);
set(gca,'ydir','normal')
frame=getframe;
writeVideo(writerObj,frame);
% movieFrames(:,i) = frame;
end
close(writerObj);
And in Matlab I get the error:
Warning: No video frames were written to this file.
The file may be invalid.
> In VideoWriter.VideoWriter>VideoWriter.close at 307
In VideoWriter.VideoWriter>VideoWriter.delete at 256
In videomaker at 2
Error using importdata (line 136)
Unable to open file.
Error in videomaker (line 11)
t=importdata(str);

Related

MATLAB: Use of vision.VideoFileWriter and vision.VideoFileReader

I'm trying to convert a .avi file with audio to a .mp4 file. I wrote this script 'avi2mp4.m' using the Computer Vision System Toolbox v7.2 with the MATLAB R2016b.
vfr = vision.VideoFileReader('Cris Drift vs Patrick.avi', 'AudioOutputPort',true);
vfw = vision.VideoFileWriter('Cris Drift vs Patrick.mp4', 'FileFormat','MPEG4', 'AudioInputPort',true, ...
'FrameRate',vfr.info.VideoFrameRate, 'Quality',90);
while ~isDone(vfr)
[frame, audio] = vfr(); % [frame, audio] = step(vfr);
vfw(frame, audio); % step(vfw, frame, audio);
end
release(vfr);
release(vfw);
but i get this error:
Error using vision.VideoFileWriter/parenReference
Too many input arguments; expected 1 (in addition to the object handle), got 2.
Error in avi2mp4 (line 16)
vfw(frame, audio);
I don't know why? I have to pass the audio data as an argument to write it with the video data. It's the same syntax as described in the MATLAB Documentation
Documentation for Video File Writer Object
Documentation for Video File Reader Object
With vision.VideoFileWriter you can write both audio and video only when the format is AVI or WMV. If you received a warning about AudioInputPort property not relevant when you set that property that means audio is not supported in that configuration.

Can't Visualize Ascii File on Matlab

I have .txt file created by an STM32 connected to a accelerometer sensors.
This file are Ascii file (probabily 8bit)
I tried to visualize on Matlab using
ZZ = load('000_LOG.TXT', '-ascii')
Error using load
Unknown text on line number 1 of ASCII file 000_LOG.TXT
so i tried
zx = load ('000_LOG.TXT')
Error using load
Unknown text on line number 1 of ASCII file 000_LOG.TXT
so i tried after reading this post importing ASCII file to Matlab
fid = fopen ('000_LOG.TXT');
>> myData = fread ('fid')
Error using fread
Invalid file identifier. Use fopen to generate a
valid file identifier.
The command "importdata" worked, but i can't convert to dec
Xw = importdata ('000_LOG.TXT')
Xw =
'|}}|}}|~}|~}|~}|}~|}~}}~}}~}}}}}~}}~}}|}}}}|}|}}~}}}}}}}|€}|}|€}}€}|...'
In fact
Wx = bin2dec(Xw)
Error using bin2dec (line 35)
Binary string must be 52 bits or less.
This is the link to the file .txt on dropbox
https://www.dropbox.com/l/s/mDoDk5puIpZaEdLth4w0Lr
Thanks for your support

How to replace the wavread(file) in matlab r2015a

I am trying to run a matlab script and in the line [s, fs] = wavread(file);,
I take the following result,
Warning: WAVREAD will be removed in a future release. Use AUDIOREAD
instead. In wavread (line 62) In MEDanalysis (line 25) Error using
wavread (line 70) Invalid Wave File. Reason: Cannot open file.
Error in MEDanalysis (line 25)
[s, fs] = wavread(file);
You have 1 warning and one error:
The Warning is about using waveread which will be removed in future versions of MATLAB.
If you want your code to compatible with newer versions of MATLAB, use audioread.
The error says something about your wave file being corrupted. Can you play it in VLC for instance?

Loading multiple '.bmp' images in MATLAB

im trying to load a group of images with the extension'.BMP' to matlab to do some process over each, and here is my code:
s=dir('*.jpg')
numel(s)
for n=1:numel(s)
load(s(n).name);
% my processes over each image
end
but i got this errur:
Error using load
Number of columns on line 3 of ASCII file
D:\Study\Memo_Master\Group Images
Comprission\Matlabs\1.bmp must be the same as
previous lines.
where '1.bmp' is a image exist in the file destination.
ANY HELP??
The load function is aimed at loading mat-files (i.e. binary data files), not images. To load images, you should use the imread function instead.
In your code:
s = dir('*.bmp');
for n = 1:numel(s)
Img = imread(s(n).name);
% my processes over each image
end
Best,

Error when load file .dat in matlab

I have problem when I try to load file .dat in Matlab.
My file .dat about speech data:
% Read data file "orig.dat" with sampling rate of 8 kHz
% create an example sound
fs=8000;
t=0:1/fs:3;
x = 1*sin(2*pi*4*t)+0.25* sin(2*pi*560*t);
% play it back
%sound(x, 8000);
wavwrite(x,fs,16,'test56.wav');
y=wavread('test56.wav')
save y.dat y
load y.dat
There is a error:
??? Error using ==> load Number of columns on line 1 of ASCII file C:\Program Files\MATLAB\R2010b\bin\doan\y.dat
must be the same as previous lines.
Error in ==> twosubband at 8 load y.dat; % Load speech data
I don't understand.
Help me fix it.
load expects a file in its own data format. Try saving y as y.mat instead of y.dat.
That is, replace y.dat in both the line where you save and the line where you load by y.mat.
That should do the trick.