I am encountering a particular problem while attempting to read a .yuv video file in opencv. My code is as follows:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main( void )
{
VideoCapture cap("video/balloons1.yuv"); // open the video file for reading
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the video file" << endl;
return -1;
}
return 0;
}
However, I keep encountering the following error:
I have installed FFMPEG following the instructions from this website: http://www.wikihow.com/Install-FFmpeg-on-Windows and the installation seems to be correct. Does anyone have any ideas of what the problem might be?
Raw YUV video file doesn't contain any metadata such like picture dimensions, timing, used pixel format or even any markers to identify the file as video file. No player can open this file without extra help, and neither can OpenCV nor ffmpeg. You need either to somehow tell OpenCV parameters of the file (not sure this even possible with OpenCV api) or convert the file into some other format.
I suggest doing latter. Probably easiest way do that is described in Using FFMPEG to losslessly convert YUV to another format for editing in Adobe Premier (this will losslessly compress video file), or you can try using some format capable of storing raw video - IIRC mxf is capable.
Just be sure to provide correct details for your particular file - correct dimensions and pixel format are crucial.
Related
How to convert image.png or image.bmp to integer array? (do not use any non-standard library)
Please ignore chunks that are not directly related to image data.(IHDR、IEND...etc.)
thank you very much.
SOLVED: I should use binary I/O function in stdio.h to read image file. thanks
If you have to read images into arrays without any image processing libraries you need two things:
You need means to read files in general.
You need to know the internal structure of the file formats you want to read.
So for png refer to https://www.w3.org/TR/2003/REC-PNG-20031110/
This document will tell you where to find the image dimensions, pixel data and other features. It's basically a manual for software developers on how to use this standard format properly.
Some image formats will require additional work like decrompression.
I have client and server, have an image in client and I want to send this to server. That image is in cv::mat format. Therefore I need to convert this matrix to binary.
I have tried memcpy(binImage,matImg.data,sizeof(matImg.data)
binImage's format is char*
How can i convert this matImg to binImg? I don't have any experience about OpenCV.
The following should do the trick:
memcpy(binImage, matImg.data, matImg.step.p[0]*matImg.rows)
However, I think you can avoid the copy and work directly with matImg.data.
I'm trying to port FFmpeg into my NaCl module.
So far, my module linked ffmpeg and SDL libraries.
It already can play YUV format video which is directed load into memory and copy into YUVOverlay buffer (it's very easy).
Now, I want to use ffmpeg to decode video, but when I call the function avformat_open_input it returns -5 when input is URL string, such as rtmp:// or mmsh://; it returns -1052488119 when input is file name, such as /saved/tmp (I mount the file system - html5fs).
There are some questions:
What means of -5 and -1052488119?
If file can't open by avformat_open_input, is it possible the input type is from buffer not from file name or url string?
If I'm not clearly about my question or description, you can tell me.
If you are doing the same thing or having the same problem, we can discuss together.
Thanks,
Jar
There is a ffmpeg port in naclports. Maybe that would be useful for you?
you can find naclports at https://chromium.googlesource.com/webports/. They were moved from http://code.google.com/p/naclports/.
Is there any direct command in FFmpeg to merge videos in iPhone. I need to do this programmatically by setting the command line argument to the FFmpeg containing the input movie files to merge and the output file name.
I just wanted to merge two .mov movie files using FFmpeg. I was trying to do this in iPhone where I was creating a command line argument containing two video fies to merge as an input parameter and the destination video file as output parameter and then calling main method of FFmpeg. But for merging videos using FFmpeg first we need to convert it to mpg format and then pass the movie files in mpg format in the command line format. This is the only way found to merge the video using FFmpeg as far as I know. Is there anybody out there done this in a different way?
To paraphrase the FFmpeg FAQ entry "How can I join video files?"
Transcode to a format that supports direct concatenation (MPEG-1, MPEG-2 PS, DV) and then back to the desired format.
Use the concat protocol to get the same effect without the intermediate files.
Use named pipes to avoid the intermediate files.
Do any of the above with the lossless yuv4mpegpipe or raw formats.
Where can I find documentation/sample code of the VOBsub subtitles format? The one that's an .idx and a .sub file.
I need to create a program that generates those subtitles. I've been looking on Google but only found how to rip them from DVD.
Thanks
VOBsub extracts the DVD subtitles raw PES from a DVD and dumps this to a .sub file. It also creates a .idx Index file with the times and byteoffsets for each and every single subtitle. The format has support for multiple tracks and can also be embedded in MP4 (by Nero) and Matroska files.
Technical specs vobsub
Technical specs from Matroska.org
Example files: Specs_and_idx-sub_files.rar
Have a look at these open source implementations:
BDSup2Sub (Java)
Subtitle Edit (C#)
guliverkli by gabest (C++) check out VSFilter and VSRip; original implementation
Son2VobSub.rar (C++)
And then there are the media players like VLC. You can also check out these threads on doom9:
http://forum.doom9.org/archive/index.php/t-87171.html
http://forum.doom9.org/archive/index.php/t-99815.html
I think your best approach would be to have a look at the sourcecode of some of the open-source media players. Some of them will have the code to interpret an .idx or .sub subtitle file.
This might be a useful starting point:
http://sourceforge.net/projects/guliverkli/