mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
added support of different surface formats to VideoWriter_GPU
added key frame handling to ffmpeg wrappers
This commit is contained in:
@@ -71,11 +71,11 @@ typedef void (*CvReleaseVideoWriter_Plugin)( void** writer );
|
||||
|
||||
OPENCV_FFMPEG_API struct OutputMediaStream_FFMPEG* create_OutputMediaStream_FFMPEG(const char* fileName, int width, int height, double fps);
|
||||
OPENCV_FFMPEG_API void release_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream);
|
||||
OPENCV_FFMPEG_API void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size);
|
||||
OPENCV_FFMPEG_API void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame);
|
||||
|
||||
typedef struct OutputMediaStream_FFMPEG* (*Create_OutputMediaStream_FFMPEG_Plugin)(const char* fileName, int width, int height, double fps);
|
||||
typedef void (*Release_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream);
|
||||
typedef void (*Write_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size);
|
||||
typedef void (*Write_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1454,9 +1454,9 @@ void CvVideoWriter_FFMPEG::close()
|
||||
struct OutputMediaStream_FFMPEG
|
||||
{
|
||||
bool open(const char* fileName, int width, int height, double fps);
|
||||
void write(unsigned char* data, int size);
|
||||
|
||||
void close();
|
||||
|
||||
void write(unsigned char* data, int size, int keyFrame);
|
||||
|
||||
// add a video output stream to the container
|
||||
static AVStream* addVideoStream(AVFormatContext *oc, CodecID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format);
|
||||
@@ -1698,13 +1698,16 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputMediaStream_FFMPEG::write(unsigned char* data, int size)
|
||||
void OutputMediaStream_FFMPEG::write(unsigned char* data, int size, int keyFrame)
|
||||
{
|
||||
// if zero size, it means the image was buffered
|
||||
if (size > 0)
|
||||
{
|
||||
AVPacket pkt;
|
||||
av_init_packet(&pkt);
|
||||
|
||||
if (keyFrame)
|
||||
pkt.flags |= PKT_FLAG_KEY;
|
||||
|
||||
pkt.stream_index = video_st_->index;
|
||||
pkt.data = data;
|
||||
@@ -1734,7 +1737,7 @@ void release_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream)
|
||||
free(stream);
|
||||
}
|
||||
|
||||
void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size)
|
||||
void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame)
|
||||
{
|
||||
stream->write(data, size);
|
||||
stream->write(data, size, keyFrame);
|
||||
}
|
||||
|
||||
@@ -1620,9 +1620,9 @@ void CvVideoWriter_FFMPEG::close()
|
||||
struct OutputMediaStream_FFMPEG
|
||||
{
|
||||
bool open(const char* fileName, int width, int height, double fps);
|
||||
void write(unsigned char* data, int size);
|
||||
|
||||
void close();
|
||||
|
||||
void write(unsigned char* data, int size, int keyFrame);
|
||||
|
||||
// add a video output stream to the container
|
||||
static AVStream* addVideoStream(AVFormatContext *oc, CodecID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format);
|
||||
@@ -1864,7 +1864,7 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputMediaStream_FFMPEG::write(unsigned char* data, int size)
|
||||
void OutputMediaStream_FFMPEG::write(unsigned char* data, int size, int keyFrame)
|
||||
{
|
||||
// if zero size, it means the image was buffered
|
||||
if (size > 0)
|
||||
@@ -1872,6 +1872,9 @@ void OutputMediaStream_FFMPEG::write(unsigned char* data, int size)
|
||||
AVPacket pkt;
|
||||
av_init_packet(&pkt);
|
||||
|
||||
if (keyFrame)
|
||||
pkt.flags |= PKT_FLAG_KEY;
|
||||
|
||||
pkt.stream_index = video_st_->index;
|
||||
pkt.data = data;
|
||||
pkt.size = size;
|
||||
@@ -1900,7 +1903,7 @@ void release_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream)
|
||||
free(stream);
|
||||
}
|
||||
|
||||
void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size)
|
||||
void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame)
|
||||
{
|
||||
stream->write(data, size);
|
||||
stream->write(data, size, keyFrame);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user