videoio: update ffmpeg backend
- fix compilation for old libraries - update codec/tag selection logic - add documentation note about MP4 container tags
This commit is contained in:
parent
424c2bddb3
commit
959d575292
@ -564,7 +564,9 @@ public:
|
|||||||
@param fourcc 4-character code of codec used to compress the frames. For example,
|
@param fourcc 4-character code of codec used to compress the frames. For example,
|
||||||
VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a
|
VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a
|
||||||
motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by
|
motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by
|
||||||
FOURCC](http://www.fourcc.org/codecs.php) page.
|
FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses
|
||||||
|
other values as fourcc code: see [ObjectType](http://www.mp4ra.org/codecs.html),
|
||||||
|
so you may receive a warning message from OpenCV about fourcc code conversion.
|
||||||
@param fps Framerate of the created video stream.
|
@param fps Framerate of the created video stream.
|
||||||
@param frameSize Size of the video frames.
|
@param frameSize Size of the video frames.
|
||||||
@param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
|
@param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
|
||||||
|
@ -1543,7 +1543,7 @@ void CvVideoWriter_FFMPEG::close()
|
|||||||
#define CV_PRINTABLE_CHAR(ch) ((ch) < 32 ? '?' : (ch))
|
#define CV_PRINTABLE_CHAR(ch) ((ch) < 32 ? '?' : (ch))
|
||||||
#define CV_TAG_TO_PRINTABLE_CHAR4(tag) CV_PRINTABLE_CHAR((tag) & 255), CV_PRINTABLE_CHAR(((tag) >> 8) & 255), CV_PRINTABLE_CHAR(((tag) >> 16) & 255), CV_PRINTABLE_CHAR(((tag) >> 24) & 255)
|
#define CV_TAG_TO_PRINTABLE_CHAR4(tag) CV_PRINTABLE_CHAR((tag) & 255), CV_PRINTABLE_CHAR(((tag) >> 8) & 255), CV_PRINTABLE_CHAR(((tag) >> 16) & 255), CV_PRINTABLE_CHAR(((tag) >> 24) & 255)
|
||||||
|
|
||||||
static inline bool cv_ff_codec_tag_match(const AVCodecTag *tags, enum AVCodecID id, unsigned int tag)
|
static inline bool cv_ff_codec_tag_match(const AVCodecTag *tags, CV_CODEC_ID id, unsigned int tag)
|
||||||
{
|
{
|
||||||
while (tags->id != AV_CODEC_ID_NONE)
|
while (tags->id != AV_CODEC_ID_NONE)
|
||||||
{
|
{
|
||||||
@ -1553,7 +1553,7 @@ static inline bool cv_ff_codec_tag_match(const AVCodecTag *tags, enum AVCodecID
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static inline bool cv_ff_codec_tag_list_match(const AVCodecTag *const *tags, enum AVCodecID id, unsigned int tag)
|
static inline bool cv_ff_codec_tag_list_match(const AVCodecTag *const *tags, CV_CODEC_ID id, unsigned int tag)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; tags && tags[i]; i++) {
|
for (i = 0; tags && tags[i]; i++) {
|
||||||
@ -1611,21 +1611,24 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
|
|||||||
#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
|
#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
|
||||||
if( (codec_id = codec_get_bmp_id( fourcc )) == CV_CODEC(CODEC_ID_NONE) )
|
if( (codec_id = codec_get_bmp_id( fourcc )) == CV_CODEC(CODEC_ID_NONE) )
|
||||||
return false;
|
return false;
|
||||||
#elif LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0)
|
#else
|
||||||
// APIchnages:
|
|
||||||
// 2012-01-31 - dd6d3b0 - lavf 54.01.0
|
|
||||||
// Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags().
|
|
||||||
if( (codec_id = av_codec_get_id(fmt->codec_tag, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
|
if( (codec_id = av_codec_get_id(fmt->codec_tag, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
|
||||||
{
|
{
|
||||||
const struct AVCodecTag * fallback_tags[] = {
|
const struct AVCodecTag * fallback_tags[] = {
|
||||||
|
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0)
|
||||||
|
// APIchanges:
|
||||||
|
// 2012-01-31 - dd6d3b0 - lavf 54.01.0
|
||||||
|
// Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags().
|
||||||
avformat_get_riff_video_tags(),
|
avformat_get_riff_video_tags(),
|
||||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 25, 100)
|
#endif
|
||||||
|
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 25, 100) && defined LIBAVFORMAT_VERSION_MICRO && LIBAVFORMAT_VERSION_MICRO >= 100
|
||||||
// APIchanges: ffmpeg only
|
// APIchanges: ffmpeg only
|
||||||
// 2014-01-19 - 1a193c4 - lavf 55.25.100 - avformat.h
|
// 2014-01-19 - 1a193c4 - lavf 55.25.100 - avformat.h
|
||||||
// Add avformat_get_mov_video_tags() and avformat_get_mov_audio_tags().
|
// Add avformat_get_mov_video_tags() and avformat_get_mov_audio_tags().
|
||||||
// TODO ffmpeg only, need to skip libav: avformat_get_mov_video_tags(),
|
avformat_get_mov_video_tags(),
|
||||||
#endif
|
#endif
|
||||||
codec_bmp_tags, NULL };
|
codec_bmp_tags, // fallback for avformat < 54.1
|
||||||
|
NULL };
|
||||||
if( (codec_id = av_codec_get_id(fallback_tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
|
if( (codec_id = av_codec_get_id(fallback_tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
|
||||||
{
|
{
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -1650,10 +1653,6 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
|
|||||||
fourcc = supported_tag;
|
fourcc = supported_tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
const struct AVCodecTag * tags[] = { codec_bmp_tags, NULL};
|
|
||||||
if( (codec_id = av_codec_get_id(tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
|
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// alloc memory for context
|
// alloc memory for context
|
||||||
|
Loading…
x
Reference in New Issue
Block a user