1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

fftools/ffmpeg_mux: return errors from of_output_packet() instead of aborting

This commit is contained in:
Anton Khirnov 2023-07-13 13:34:32 +02:00
parent 2b4afe8169
commit e0f4259689
4 changed files with 21 additions and 17 deletions

View File

@ -1120,7 +1120,9 @@ static int process_input(int file_index)
OutputStream *ost = ist->outputs[oidx];
OutputFile *of = output_files[ost->file_index];
close_output_stream(ost);
of_output_packet(of, ost, NULL);
ret = of_output_packet(of, ost, NULL);
if (ret < 0)
return ret;
}
}

View File

@ -830,7 +830,7 @@ void of_close(OutputFile **pof);
void of_enc_stats_close(void);
void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt);
int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt);
/**
* @param dts predicted packet dts in AV_TIME_BASE_Q

View File

@ -559,7 +559,9 @@ int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
}
pkt->dts = pkt->pts;
of_output_packet(of, ost, pkt);
ret = of_output_packet(of, ost, pkt);
if (ret < 0)
return ret;
}
return 0;
@ -752,8 +754,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
av_assert0(frame); // should never happen during flushing
return 0;
} else if (ret == AVERROR_EOF) {
of_output_packet(of, ost, NULL);
return ret;
ret = of_output_packet(of, ost, NULL);
return ret < 0 ? ret : AVERROR_EOF;
} else if (ret < 0) {
av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
return ret;
@ -790,7 +792,9 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
e->packets_encoded++;
of_output_packet(of, ost, pkt);
ret = of_output_packet(of, ost, pkt);
if (ret < 0)
return ret;
}
av_assert0(0);

View File

@ -330,7 +330,7 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost)
return 0;
}
void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
{
Muxer *mux = mux_from_of(of);
MuxStream *ms = ms_from_ost(ost);
@ -359,7 +359,7 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
while (!bsf_eof) {
ret = av_bsf_receive_packet(ms->bsf_ctx, ms->bsf_pkt);
if (ret == AVERROR(EAGAIN))
return;
return 0;
else if (ret == AVERROR_EOF)
bsf_eof = 1;
else if (ret < 0) {
@ -377,16 +377,14 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
goto mux_fail;
}
return;
return 0;
mux_fail:
err_msg = "submitting a packet to the muxer";
fail:
av_log(ost, AV_LOG_ERROR, "Error %s\n", err_msg);
if (exit_on_error)
exit_program(1);
return exit_on_error ? ret : 0;
}
int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
@ -405,10 +403,8 @@ int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
pkt = NULL;
// EOF: flush output bitstream filters.
if (!pkt) {
of_output_packet(of, ost, NULL);
return 0;
}
if (!pkt)
return of_output_packet(of, ost, NULL);
if (!ms->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) &&
!ms->copy_initial_nonkeyframes)
@ -461,7 +457,9 @@ int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
}
}
of_output_packet(of, ost, opkt);
ret = of_output_packet(of, ost, opkt);
if (ret < 0)
return ret;
ms->streamcopy_started = 1;