You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fftools/ffmpeg_enc: return errors from enc_subtitle() instead of aborting
This commit is contained in:
@@ -804,7 +804,7 @@ int enc_alloc(Encoder **penc, const AVCodec *codec);
|
|||||||
void enc_free(Encoder **penc);
|
void enc_free(Encoder **penc);
|
||||||
|
|
||||||
int enc_open(OutputStream *ost, AVFrame *frame);
|
int enc_open(OutputStream *ost, AVFrame *frame);
|
||||||
void 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);
|
void enc_frame(OutputStream *ost, AVFrame *frame);
|
||||||
void enc_flush(void);
|
void enc_flush(void);
|
||||||
|
|
||||||
|
@@ -439,7 +439,9 @@ static int process_subtitle(InputStream *ist, AVFrame *frame)
|
|||||||
if (!ost->enc || ost->type != AVMEDIA_TYPE_SUBTITLE)
|
if (!ost->enc || ost->type != AVMEDIA_TYPE_SUBTITLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
enc_subtitle(output_files[ost->file_index], ost, subtitle);
|
ret = enc_subtitle(output_files[ost->file_index], ost, subtitle);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -462,7 +462,7 @@ static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
||||||
{
|
{
|
||||||
Encoder *e = ost->enc;
|
Encoder *e = ost->enc;
|
||||||
int subtitle_out_max_size = 1024 * 1024;
|
int subtitle_out_max_size = 1024 * 1024;
|
||||||
@@ -473,13 +473,11 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
|||||||
|
|
||||||
if (sub->pts == AV_NOPTS_VALUE) {
|
if (sub->pts == AV_NOPTS_VALUE) {
|
||||||
av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
|
av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
|
||||||
if (exit_on_error)
|
return exit_on_error ? AVERROR(EINVAL) : 0;
|
||||||
exit_program(1);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (ost->finished ||
|
if (ost->finished ||
|
||||||
(of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time))
|
(of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
enc = ost->enc_ctx;
|
enc = ost->enc_ctx;
|
||||||
|
|
||||||
@@ -501,11 +499,11 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
|||||||
AVSubtitle local_sub = *sub;
|
AVSubtitle local_sub = *sub;
|
||||||
|
|
||||||
if (!check_recording_time(ost, pts, AV_TIME_BASE_Q))
|
if (!check_recording_time(ost, pts, AV_TIME_BASE_Q))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
ret = av_new_packet(pkt, subtitle_out_max_size);
|
ret = av_new_packet(pkt, subtitle_out_max_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
report_and_exit(AVERROR(ENOMEM));
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
local_sub.pts = pts;
|
local_sub.pts = pts;
|
||||||
// start_display_time is required to be 0
|
// start_display_time is required to be 0
|
||||||
@@ -525,7 +523,7 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
|||||||
subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, &local_sub);
|
subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, &local_sub);
|
||||||
if (subtitle_out_size < 0) {
|
if (subtitle_out_size < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n");
|
av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n");
|
||||||
exit_program(1);
|
return subtitle_out_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_shrink_packet(pkt, subtitle_out_size);
|
av_shrink_packet(pkt, subtitle_out_size);
|
||||||
@@ -544,6 +542,8 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
|||||||
|
|
||||||
of_output_packet(of, ost, pkt);
|
of_output_packet(of, ost, pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enc_stats_write(OutputStream *ost, EncStats *es,
|
void enc_stats_write(OutputStream *ost, EncStats *es,
|
||||||
|
Reference in New Issue
Block a user