diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-07-12 19:52:19 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-07-15 11:02:11 +0200 |
commit | 2e742a2c3c05e9d2ea86216daaf35cbdd108f3aa (patch) | |
tree | 2796a30001dbcce35a6840158bb8226136cced18 /fftools/ffmpeg_mux.c | |
parent | 464a5e8e7681267501cb4a5e96ad040522a67d4e (diff) | |
download | ffmpeg-2e742a2c3c05e9d2ea86216daaf35cbdd108f3aa.tar.gz |
fftools/ffmpeg_mux: return errors from of_streamcopy() instead of aborting
Diffstat (limited to 'fftools/ffmpeg_mux.c')
-rw-r--r-- | fftools/ffmpeg_mux.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index ca32967cd8..a6cc824496 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -389,13 +389,14 @@ fail: } -void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) +int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) { OutputFile *of = output_files[ost->file_index]; MuxStream *ms = ms_from_ost(ost); int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->mux_timebase); AVPacket *opkt = ms->pkt; + int ret; av_packet_unref(opkt); @@ -406,26 +407,27 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) // EOF: flush output bitstream filters. if (!pkt) { of_output_packet(of, ost, NULL); - return; + return 0; } if (!ms->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) && !ms->copy_initial_nonkeyframes) - return; + return 0; if (!ms->streamcopy_started) { if (!ms->copy_prior_start && (pkt->pts == AV_NOPTS_VALUE ? dts < ms->ts_copy_start : pkt->pts < av_rescale_q(ms->ts_copy_start, AV_TIME_BASE_Q, pkt->time_base))) - return; + return 0; if (of->start_time != AV_NOPTS_VALUE && dts < of->start_time) - return; + return 0; } - if (av_packet_ref(opkt, pkt) < 0) - exit_program(1); + ret = av_packet_ref(opkt, pkt); + if (ret < 0) + return ret; opkt->time_base = ost->mux_timebase; @@ -455,13 +457,15 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) av_log(NULL, AV_LOG_ERROR, "Subtitle heartbeat logic failed in %s! (%s)\n", __func__, av_err2str(ret)); - exit_program(1); + return ret; } } of_output_packet(of, ost, opkt); ms->streamcopy_started = 1; + + return 0; } static int thread_stop(Muxer *mux) |