How to use libavcodec in Qt4 to access individual video frames?
After verifying that the video stream can be decoded by libavcodec by compiling this example , I moved the source code to my C ++ program. Now it av_open_input_file()suddenly cannot open my video file (returning an error code: -2).
The call is as follows:
...
avcodec_register_all();
QString videoFileName("/absolute/path/to/video.avi");
const char* fileName = videoFileName.toStdString().c_str();
int err = 0;
if((err = av_open_input_file(&pFormatCtx, fileName, NULL, 0, NULL)) != 0)
{
doErrorHandling(err, fileName);
}
When I look at the const char* fileNameinside of the debugger, it looks right. Am I making some basic mistake when mixing C and C ++ code (for the first attempt, I just dumped the code from the example into the class constructor)?
Note . To get the compilation application, I include the headers as follows:
extern "C"
{
#define __STDC_CONSTANT_MACROS
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
- :
av_open_input_file(&pFormatCtx, "/home/bjoernz/video.avi", NULL, 0, NULL);
(avcodec_sample.0.5.0.c) g++.