mirror of https://git.ffmpeg.org/ffmpeg.git
fftools/ffmpeg_mux: return errors from of_output_packet() instead of aborting
This commit is contained in:
parent
2b4afe8169
commit
e0f4259689
|
@ -1120,7 +1120,9 @@ static int process_input(int file_index)
|
||||||
OutputStream *ost = ist->outputs[oidx];
|
OutputStream *ost = ist->outputs[oidx];
|
||||||
OutputFile *of = output_files[ost->file_index];
|
OutputFile *of = output_files[ost->file_index];
|
||||||
close_output_stream(ost);
|
close_output_stream(ost);
|
||||||
of_output_packet(of, ost, NULL);
|
ret = of_output_packet(of, ost, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ void of_close(OutputFile **pof);
|
||||||
|
|
||||||
void of_enc_stats_close(void);
|
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
|
* @param dts predicted packet dts in AV_TIME_BASE_Q
|
||||||
|
|
|
@ -559,7 +559,9 @@ int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
|
||||||
}
|
}
|
||||||
pkt->dts = pkt->pts;
|
pkt->dts = pkt->pts;
|
||||||
|
|
||||||
of_output_packet(of, ost, pkt);
|
ret = of_output_packet(of, ost, pkt);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -752,8 +754,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
|
||||||
av_assert0(frame); // should never happen during flushing
|
av_assert0(frame); // should never happen during flushing
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ret == AVERROR_EOF) {
|
} else if (ret == AVERROR_EOF) {
|
||||||
of_output_packet(of, ost, NULL);
|
ret = of_output_packet(of, ost, NULL);
|
||||||
return ret;
|
return ret < 0 ? ret : AVERROR_EOF;
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
|
av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -790,7 +792,9 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
|
||||||
|
|
||||||
e->packets_encoded++;
|
e->packets_encoded++;
|
||||||
|
|
||||||
of_output_packet(of, ost, pkt);
|
ret = of_output_packet(of, ost, pkt);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_assert0(0);
|
av_assert0(0);
|
||||||
|
|
|
@ -330,7 +330,7 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost)
|
||||||
return 0;
|
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);
|
Muxer *mux = mux_from_of(of);
|
||||||
MuxStream *ms = ms_from_ost(ost);
|
MuxStream *ms = ms_from_ost(ost);
|
||||||
|
@ -359,7 +359,7 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
|
||||||
while (!bsf_eof) {
|
while (!bsf_eof) {
|
||||||
ret = av_bsf_receive_packet(ms->bsf_ctx, ms->bsf_pkt);
|
ret = av_bsf_receive_packet(ms->bsf_ctx, ms->bsf_pkt);
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret == AVERROR(EAGAIN))
|
||||||
return;
|
return 0;
|
||||||
else if (ret == AVERROR_EOF)
|
else if (ret == AVERROR_EOF)
|
||||||
bsf_eof = 1;
|
bsf_eof = 1;
|
||||||
else if (ret < 0) {
|
else if (ret < 0) {
|
||||||
|
@ -377,16 +377,14 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
|
||||||
goto mux_fail;
|
goto mux_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
mux_fail:
|
mux_fail:
|
||||||
err_msg = "submitting a packet to the muxer";
|
err_msg = "submitting a packet to the muxer";
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
av_log(ost, AV_LOG_ERROR, "Error %s\n", err_msg);
|
av_log(ost, AV_LOG_ERROR, "Error %s\n", err_msg);
|
||||||
if (exit_on_error)
|
return exit_on_error ? ret : 0;
|
||||||
exit_program(1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
|
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;
|
pkt = NULL;
|
||||||
|
|
||||||
// EOF: flush output bitstream filters.
|
// EOF: flush output bitstream filters.
|
||||||
if (!pkt) {
|
if (!pkt)
|
||||||
of_output_packet(of, ost, NULL);
|
return of_output_packet(of, ost, NULL);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ms->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) &&
|
if (!ms->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) &&
|
||||||
!ms->copy_initial_nonkeyframes)
|
!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;
|
ms->streamcopy_started = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue