How do I force MATLAB functions to use a different codec when I need to play an AVI file?
I am using windows7 and I find that indeo5 codec is not working properly because of the OS.
All code works fine on XP.
Thanks!
If your question is about how to play an avi using a codec other than the one used to create it, you'll have to use some kind of image conversion software ( RAD video tools aka bink and smacker is popular and free ) to recompress the movie using the new codec. There may be some loss of video quality.
If your question is how to tell MATLAB to create an avi using a different codec, type help avifile to see the full documentation.
If your problem is that MATLAB is choking on a codec it says it supports and if you're using 64 bit MATLAB, I've had this problem. The short answer, unfortunately, is that there are no 64 bit codecs that work with MATLAB. There are two workarounds, and they both suck. One is to install 32 bit MATLAB and use that when you need to access an avi. The other is to use some kind of image conversion software to convert your avi to an image stack, then load that with MATLAB.
(EDIT: In newer versions of MATLAB, you can use the VideoWriter object to write MP4 and other compressed formats in 64 bit windows)
Related
I need to encode a raw video stream captured from a camera to h264. I'm using an NVIDIA Pascal GPU under Windows 7 and am trying to use FFmpeg to control the h264_nvenc, rather than the NVIDIA SDK directly.
Using libavcodec, I've got a program that successfully encodes the input stream using avcodec_encode_video2(). This function takes the input image from a buffer in RAM and DMAs it to the GPU where it is encoded.
I now want to encode an image that is already on the GPU (in a CUDA buffer). Looking at the documentation and various examples for FFmpeg, I didn't find any pointers as to how to do this.
Does anybody know if this is possible, and if so how to do it?
I am trying to use videoWriter in Matlab 2013a on a Windows 7 64 bit machine. I also have Matlab 2009a installed (which could be the issue)
My code fails here:
vid = VideoWriter('TestVideo');
This gives me the following error:
Error using VideoWriter (line 240)
Undefined variable "asyncio" or class "asyncio.Channel".
Now if I do this:
vid = VideoWriter('TestVideo.mp4','MPEG-4');
I get this error:
Error using VideoWriter (line 168)
The specified profile is not valid.
I tried installing codecs, but that didn't help.
I read somewhere that someone had a similar problem, and it was due to a corrupt path and it could be caused by an older installation of Matlab (2007), but nothing about what was eventually done to fix it. I have tried to add the asyncio folder in the Matlab directory to the Matlab path, but again no luck.
I have further tried to find out what videoWriter does regarding asyncio, but cannot find any clues in the code, and I honestly don't really know what asyncio is.
Uninstalling Matlab 2009a is not an option.
So can anyone help me please?
BR Gorm
You need to use the second way of invoking VideoWriter.... so doing:
vid = VideoWriter('TestVideo.mp4','MPEG-4');
However, you are getting this error:
Error using VideoWriter (line 168) The specified profile is not valid.
This is due to the fact that you probably don't have the MPEG-4 codecs installed on your computer. You can verify this by doing this in MATLAB:
profiles = VideoWriter.getProfiles()
Run the above code in the Command Prompt. You get a list of all possible profiles that you can use for writing a video to file using VideoWriter. For example, I'm using MATLAB R2013a on Mac OS and this is what I get:
>> profiles = VideoWriter.getProfiles()
Summary of installed VideoWriter profiles:
Name Description
---------------- -----------------------------------------------------------------------
Archival Video file compression with JPEG 2000 codec with lossless mode enabled.
Grayscale AVI An AVI file with Grayscale Video Data
Indexed AVI An AVI file with Indexed Video Data
MPEG-4 A MPEG-4 file with H.264 Compression
Motion JPEG 2000 Video file compression with JPEG 2000 codec.
Motion JPEG AVI An AVI file with Motion JPEG compression
Uncompressed AVI An AVI file with uncompressed RGB24 video data
If you don't see MPEG-4 on your list of profiles, then you currently don't have the profile installed. As such, you will have to use one of the provided profiles that MATLAB has for you.
Since you're running Windows, one suggestion I have is to install the Windows 7 Codec Pack suite: http://www.windows7codecs.com/. I know you said that when you installed codecs, it didn't work but you can try the above link if you haven't done it already.
The above website contains all of the codecs you would need to play video files in Windows. This will hopefully allow you to use VideoWriter once you install the codecs.
So I found an answer to my own question. It was the path that was broken. Problem can be fixed easily by setting the Matlab search path to default.
This is an old question, but I also wanted to add my two cents. What solved the problem for me was looking at my Windows version. Many companies have a Windows N version installed on their computers. These versions don't have all of the codecs and software, needed for playing and creating media files. So if you are using Matlab at work this might be the problem.
The fix is downloading the Windows Media Feature Pack for N Versions and to make sure that no other codec packs, like K-Lite are installed.
I'm looking to output four channels of audio simultaneously from MATLAB using an external soundcard (Creative Soundblaster X-Fi Surround 5.1 Pro USB) and haven't yet found a working solution.
As far as I understand it, MATLAB's audioplayer object can only output a stereo signal, so I've tried two alternatives: playrec and pa_wavplay. Both appear to do precisely what I need, but seem to recognize the soundcard as a two-channel device only.
Any advice would be terrific. Thanks for reading.
(The MATLAB version is R2007b and the only available toolbox is the Signal Processing Toolbox.)
I've got a bit of experience of pa_wavplay and found it dealt with large numbers of inputs/output without any problems. I'd suspect the problem is with your audio interface.
While it can output 5.1, it's quite possibly producing those "additional" channels itself by decoding a Dolby Digital stream once in the device. This suggests the interface won't allow you to output 6 six channels of PCM audio as such.
If you're determined to use this device and prepared to get your hands dirty you could always try encoding your audio as ac3 yourself, but I guess you'd have to do this outside Matlab.
I have used video.MultimediaFileWriter to write frames from input AVI video file to an output AVI video file. After the output file is created the size of the output file is very large. I have used VideoCompressor's provided in MATLAB options. For example: for an input video size of 3.42MB after using compression techniques provided by MATLAB the output video size is 98.5MB.
Can anyone tell me how to bring the output AVI file to size of the input file?
The creation of videos using H.264 was added in R2012a. Older versions support the less efficient codecs MJPEG and DV, which probably explain your large files. However, this is not a major problem because you can recompress your videos using free tools, such as VirtualDub and x264. Here is a tutorial.
I am dealing now with DDSM database (Digital Database for Screening Mammography) .. its disadvantage is its extension. It is extension is ljpeg (lossless jpeg) which it is very poorly supported extension. I want to read them using matlab or converting them to any other type which is widely supported. thank
I know there is a working version of DDSM's jpeg program for linux at http://www.cs.unibo.it/~roffilli/sw.html
I compiled and tested it. I used the MATLAB code as described here to view the images.
It displays correctly only for some scanners.
As described in the paper http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.111.3846
When properly compiled, the DDSM software outputs the image data as a stream of raw bytes; one then has to normalise these according to the model of digitiser used to image the original films and then create an image file that is readable by one’s image analysis software environment.
*EDIT: *
I found a complete solution that downloads, normalizes (based on the scanner) and converts the DDSM image to PNG format. Dr. Chris Rose wrote that program, please download it on his website
http://microserf.org.uk/academic/Software.html