fftools/ffmpeg_enc: return errors from enc_frame() instead of aborting
This commit is contained in:
parent
c4b074676a
commit
80a64800ea
@ -814,7 +814,7 @@ void enc_free(Encoder **penc);
|
|||||||
|
|
||||||
int enc_open(OutputStream *ost, AVFrame *frame);
|
int enc_open(OutputStream *ost, AVFrame *frame);
|
||||||
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub);
|
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub);
|
||||||
void enc_frame(OutputStream *ost, AVFrame *frame);
|
int enc_frame(OutputStream *ost, AVFrame *frame);
|
||||||
void enc_flush(void);
|
void enc_flush(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1129,17 +1129,19 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
|
|||||||
av_frame_move_ref(e->last_frame, frame);
|
av_frame_move_ref(e->last_frame, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enc_frame(OutputStream *ost, AVFrame *frame)
|
int enc_frame(OutputStream *ost, AVFrame *frame)
|
||||||
{
|
{
|
||||||
OutputFile *of = output_files[ost->file_index];
|
OutputFile *of = output_files[ost->file_index];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = enc_open(ost, frame);
|
ret = enc_open(ost, frame);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
exit_program(1);
|
return ret;
|
||||||
|
|
||||||
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame);
|
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame);
|
||||||
else do_audio_out(of, ost, frame);
|
else do_audio_out(of, ost, frame);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enc_flush(void)
|
void enc_flush(void)
|
||||||
|
@ -1722,8 +1722,11 @@ int reap_filters(FilterGraph *fg, int flush)
|
|||||||
av_log(fgp, AV_LOG_WARNING,
|
av_log(fgp, AV_LOG_WARNING,
|
||||||
"Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret));
|
"Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret));
|
||||||
} else if (flush && ret == AVERROR_EOF && ofp->got_frame &&
|
} else if (flush && ret == AVERROR_EOF && ofp->got_frame &&
|
||||||
av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO)
|
av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) {
|
||||||
enc_frame(ost, NULL);
|
ret = enc_frame(ost, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1759,8 +1762,11 @@ int reap_filters(FilterGraph *fg, int flush)
|
|||||||
if (ost->type == AVMEDIA_TYPE_VIDEO)
|
if (ost->type == AVMEDIA_TYPE_VIDEO)
|
||||||
fd->frame_rate_filter = av_buffersink_get_frame_rate(filter);
|
fd->frame_rate_filter = av_buffersink_get_frame_rate(filter);
|
||||||
|
|
||||||
enc_frame(ost, filtered_frame);
|
ret = enc_frame(ost, filtered_frame);
|
||||||
av_frame_unref(filtered_frame);
|
av_frame_unref(filtered_frame);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ofp->got_frame = 1;
|
ofp->got_frame = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user