videoio: fix some issues in ffmpeg error processing
This commit is contained in:
parent
959d575292
commit
3f2666778a
@ -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,
|
|||||||
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()
|
|||||||
|
|
||||||
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
|
|||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user