1#ifndef __OPENCV_FFMPEG_H__ 2#define __OPENCV_FFMPEG_H__ 3 4#ifdef __cplusplus 5extern "C" 6{ 7#endif 8 9#if defined WIN32 || defined _WIN32 10# define OPENCV_FFMPEG_API __declspec(dllexport) 11#elif defined __GNUC__ && __GNUC__ >= 4 12# define OPENCV_FFMPEG_API __attribute__ ((visibility ("default"))) 13#else 14# define OPENCV_FFMPEG_API 15#endif 16 17enum 18{ 19 CV_FFMPEG_CAP_PROP_POS_MSEC=0, 20 CV_FFMPEG_CAP_PROP_POS_FRAMES=1, 21 CV_FFMPEG_CAP_PROP_POS_AVI_RATIO=2, 22 CV_FFMPEG_CAP_PROP_FRAME_WIDTH=3, 23 CV_FFMPEG_CAP_PROP_FRAME_HEIGHT=4, 24 CV_FFMPEG_CAP_PROP_FPS=5, 25 CV_FFMPEG_CAP_PROP_FOURCC=6, 26 CV_FFMPEG_CAP_PROP_FRAME_COUNT=7 27}; 28 29 30OPENCV_FFMPEG_API struct CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG(const char* filename); 31OPENCV_FFMPEG_API struct CvCapture_FFMPEG_2* cvCreateFileCapture_FFMPEG_2(const char* filename); 32OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG(struct CvCapture_FFMPEG* cap, 33 int prop, double value); 34OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG_2(struct CvCapture_FFMPEG_2* cap, 35 int prop, double value); 36OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG(struct CvCapture_FFMPEG* cap, int prop); 37OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG_2(struct CvCapture_FFMPEG_2* cap, int prop); 38OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG(struct CvCapture_FFMPEG* cap); 39OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG_2(struct CvCapture_FFMPEG_2* cap); 40OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG(struct CvCapture_FFMPEG* capture, unsigned char** data, 41 int* step, int* width, int* height, int* cn); 42OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG_2(struct CvCapture_FFMPEG_2* capture, unsigned char** data, 43 int* step, int* width, int* height, int* cn); 44OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG(struct CvCapture_FFMPEG** cap); 45OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG_2(struct CvCapture_FFMPEG_2** cap); 46OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG* cvCreateVideoWriter_FFMPEG(const char* filename, 47 int fourcc, double fps, int width, int height, int isColor ); 48OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG_2* cvCreateVideoWriter_FFMPEG_2(const char* filename, 49 int fourcc, double fps, int width, int height, int isColor ); 50 51OPENCV_FFMPEG_API int cvWriteFrame_FFMPEG(struct CvVideoWriter_FFMPEG* writer, const unsigned char* data, 52 int step, int width, int height, int cn, int origin); 53 54OPENCV_FFMPEG_API void cvReleaseVideoWriter_FFMPEG(struct CvVideoWriter_FFMPEG** writer); 55 56typedef void* (*CvCreateFileCapture_Plugin)( const char* filename ); 57typedef void* (*CvCreateCameraCapture_Plugin)( int index ); 58typedef int (*CvGrabFrame_Plugin)( void* capture_handle ); 59typedef int (*CvRetrieveFrame_Plugin)( void* capture_handle, unsigned char** data, int* step, 60 int* width, int* height, int* cn ); 61typedef int (*CvSetCaptureProperty_Plugin)( void* capture_handle, int prop_id, double value ); 62typedef double (*CvGetCaptureProperty_Plugin)( void* capture_handle, int prop_id ); 63typedef void (*CvReleaseCapture_Plugin)( void** capture_handle ); 64typedef void* (*CvCreateVideoWriter_Plugin)( const char* filename, int fourcc, 65 double fps, int width, int height, int iscolor ); 66typedef int (*CvWriteFrame_Plugin)( void* writer_handle, const unsigned char* data, int step, 67 int width, int height, int cn, int origin); 68typedef void (*CvReleaseVideoWriter_Plugin)( void** writer ); 69 70/* 71 * For CUDA encoder 72 */ 73 74OPENCV_FFMPEG_API struct OutputMediaStream_FFMPEG* create_OutputMediaStream_FFMPEG(const char* fileName, int width, int height, double fps); 75OPENCV_FFMPEG_API void release_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream); 76OPENCV_FFMPEG_API void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame); 77 78typedef struct OutputMediaStream_FFMPEG* (*Create_OutputMediaStream_FFMPEG_Plugin)(const char* fileName, int width, int height, double fps); 79typedef void (*Release_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream); 80typedef void (*Write_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame); 81 82/* 83 * For CUDA decoder 84 */ 85 86OPENCV_FFMPEG_API struct InputMediaStream_FFMPEG* create_InputMediaStream_FFMPEG(const char* fileName, int* codec, int* chroma_format, int* width, int* height); 87OPENCV_FFMPEG_API void release_InputMediaStream_FFMPEG(struct InputMediaStream_FFMPEG* stream); 88OPENCV_FFMPEG_API int read_InputMediaStream_FFMPEG(struct InputMediaStream_FFMPEG* stream, unsigned char** data, int* size, int* endOfFile); 89 90typedef struct InputMediaStream_FFMPEG* (*Create_InputMediaStream_FFMPEG_Plugin)(const char* fileName, int* codec, int* chroma_format, int* width, int* height); 91typedef void (*Release_InputMediaStream_FFMPEG_Plugin)(struct InputMediaStream_FFMPEG* stream); 92typedef int (*Read_InputMediaStream_FFMPEG_Plugin)(struct InputMediaStream_FFMPEG* stream, unsigned char** data, int* size, int* endOfFile); 93 94#ifdef __cplusplus 95} 96#endif 97 98#endif 99