Read DNG file in Matlab - matlab

I am trying to read dng files from iphoneX.
I read the link https://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/
But the error message is 'Reference to non-existent field 'SubIFDs'.'
info=imfinfo(dng_file_path);
info.SubIFDs{1} %where the error pop up
tiffHandle=Tiff((dng_file_path),'r');
offsets=TiffHandle.getTag('SubIFD');
setSubDirectory(TiffHandle,offsets(1));
CFA=double(read(TiffHandle));

The DNG files from iphone seem to be compressed (lossless jpeg compression). Try running the file through DNG Converter with the preferences set to Uncompressed. Then try that in Matlab.

Related

How to decode a large bytes synchronously (excel file)

I am using excel package version 2.0.0-null-safety-3 to read an excel file,
For small files, it looks good
But when reading a large file, the interface stops until the file is read
Excel.decodeBytes(_bytes);
decodeBytes method => sync is not supported
Is there a way to make the process synchronous
To be able to show the (download bar or waiting dialog) to the user
Thanks in advance.
Use Compute For Large Bytes of Data
await compute(function,param)
Flutter Compute

Unable to parse MP4 files -MemoryAllocationException: Tried to allocate X bytes, but the limit for this record type is:Y

I am using Tika server to fetch metadata and contents of various file formats. I am using server with fileUrl enabled.
When parsing .mov file which are created using quicktime screen record, it gives me the following error.
Text extraction failed (null) org.apache.tika.exception.TikaException:
Unexpected RuntimeException from
org.apache.tika.parser.mp4.MP4Parser#354bc1a2 at
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:293)
at
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
Caused by: org.mp4parser.MemoryAllocationException: Tried to allocate
1399026269 bytes, but the limit for this record type is: 536870912. If
you believe this file is not corrupt, please open a ticket on github
to increase the maximum allowable size for this record type. at
org.mp4parser.tools.MemoryUtils.allocateByteBuffer(MemoryUtils.java:30)
at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:100) at
org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:115)
The size of the file is just 20Mb. Other type of .mov files with
content-type="video/quicktime"
is getting parsed with out any error. I connected the debug port and i see that it fails when converting to new IsoFile().
Any help to fix this is highly appreciated.
I start the server as shown below.
java -jar tikaserver-1.24.1.jar -enableFileUrl -enableUnsecureFeatures

Extracting audio from video files

I just received a 30 day trial of the Computer Vision System Toolbox, and I just tested it out. I found this code online that separates video from audio:
file='movie.AVI';
file1='targetfile.wav';
hmfr= video.MultimediaFileReader(file,'AudioOutputPort',true,'VideoOutputPort',false);
hmfw = video.MultimediaFileWriter(file1,'AudioInputPort',true,'FileFormat','WAV');
while ~isDone(hmfr)
audioFrame = step(hmfr);
step(hmfw,audioFrame);
end
close(hmfw);
close(hmfr);
but I can't run it, I only get the error:
Undefined variable "video" or class "video.MultimediaFileReader".
I'm not quite sure what this means, does it refer to my code or the computer vision system toolbox? I checked, I have all the requirements and the add-on manager says it's properly installed, so I'm not quite sure why I get this error.
I think your task is quite easier than you think it is. It can be done without any reliance on toolboxes.
That's how:-
1. Read your video file and get its sample rate using audioread.
2. Then use audiowrite to write it as an audio file.
[input_file, Fs] = audioread('movie.AVI');
audiowrite('target_file.WAV', input_file, Fs);
%If your path is set to default then MATLAB may give you 'Permission Denied' Error.
%Change the path or give different full path like: 'D:\target_file.WAV' while audiowriting

Matlab: Error using VideoFileReader/setup

I'm using this code:
h = vision.VideoFileReader('num2.avi')
h =
System: vision.VideoFileReader
Properties:
Filename: '/Users/LoFe/Documents/BME/Work/Work/Work/num2.avi'
PlayCount: Inf
ImageColorSpace: 'RGB'
VideoOutputDataType: 'single'
It is working well, but when I want to call step on it, i get this:
while ~isDone(h)
hFrame = step(h);
end
Error using VideoFileReader/setup
Could not open the specified file.
Error in
/Applications/MATLAB_R2013a.app/toolbox/matlab/system/+matlab/+system/+mixin
/FiniteSource.p>FiniteSource.isDone
(line 39)
I'm using MATLAB 2013a, on OS X (Mavericks), what should I do? It is working fine on Windows 7.
As we discussed in the comments, the codec that was used to encode the video is may not supported on your Mac. For MATLAB, the supported codecs that the CVST video reader can read in are different between Mac and Windows.
As such, try re-encoding your video into a format that is native to the Mac, like a QuickTime movie file, or an MP4 file. HandBrake is a perfect tool to do this for you.
Also, perhaps try using MATLAB's native VideoReader class to see if you can read the file and extract video frames. Take a look at its documentation for more details: http://mathworks.com/help/matlab/ref/videoreader-class.html.
However, it looks like you have resolved the error, as converting it to a QuickTime movie file worked.
Glad I could help!

Reading a movie file in Matlab

I am trying to read a movie in avi format. But it's giving me the following error:
xyloObj = mmreader('1.avi',[1 5]);
??? Initialization failed. (No combination of intermediate filters could be found to make the connection.)
Error in ==>
mmreader.mmreader>mmreader.init at 423
obj.MMReaderImpl = audiovideo.mmreader(fullName);
Error in ==>
mmreader.mmreader>mmreader.mmreader at 133
obj.init(fileName);
Kindly help me
The likely source of the error is that you are missing the proper codec required to read the given AVI file. Apparently, this can often happen when using 64-bit versions of MATLAB on 64-bit Windows platforms. There are a number of solutions you can try given in this technical support documentation from the MathWorks.
First, can you play it with another application (such as VLC player, Windows Media Player, QuickTime, etc.) on your computer?
If yes, go to gnovice's link.
If no, go get the GSpot codec information tool which is very useful for determining which codec you need. Download the codec and make it work with a video player, then Matlab.
This pdf explains how to solve your problem. Or just use:
vid = aviread('Vid261.avi');
vi = frame2im(vid(1)) ;