Commit 3f266677 authored by Alexander Alekhin's avatar Alexander Alekhin

videoio: fix some issues in ffmpeg error processing

parent 959d5752
...@@ -1739,7 +1739,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, ...@@ -1739,7 +1739,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
/* find the video encoder */ /* find the video encoder */
codec = avcodec_find_encoder(c->codec_id); codec = avcodec_find_encoder(c->codec_id);
if (!codec) { if (!codec) {
fprintf(stderr, "Could not find encoder for codec id %d: %s", c->codec_id, icvFFMPEGErrStr( fprintf(stderr, "Could not find encoder for codec id %d: %s\n", c->codec_id, icvFFMPEGErrStr(
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0) #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
AVERROR_ENCODER_NOT_FOUND AVERROR_ENCODER_NOT_FOUND
#else #else
...@@ -1763,7 +1763,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, ...@@ -1763,7 +1763,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
avcodec_open(c, codec) avcodec_open(c, codec)
#endif #endif
) < 0) { ) < 0) {
fprintf(stderr, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err)); fprintf(stderr, "Could not open codec '%s': %s\n", codec->name, icvFFMPEGErrStr(err));
return false; return false;
} }
...@@ -1967,6 +1967,13 @@ void OutputMediaStream_FFMPEG::close() ...@@ -1967,6 +1967,13 @@ void OutputMediaStream_FFMPEG::close()
AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format) AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format)
{ {
AVCodec* codec = avcodec_find_encoder(codec_id);
if (!codec)
{
fprintf(stderr, "Could not find encoder for codec id %d\n", codec_id);
return NULL;
}
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0) #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0)
AVStream* st = avformat_new_stream(oc, 0); AVStream* st = avformat_new_stream(oc, 0);
#else #else
...@@ -1998,8 +2005,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC ...@@ -1998,8 +2005,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
c->width = w; c->width = w;
c->height = h; c->height = h;
AVCodec* codec = avcodec_find_encoder(c->codec_id);
// time base: this is the fundamental unit of time (in seconds) in terms // time base: this is the fundamental unit of time (in seconds) in terms
// of which frame timestamps are represented. for fixed-fps content, // of which frame timestamps are represented. for fixed-fps content,
// timebase should be 1/framerate and timestamp increments should be // timebase should be 1/framerate and timestamp increments should be
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment