mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
avformat/mpegenc: Ignore max_delay if no other options remain
Fixes assertion failure Fixes Ticket4335 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
2b4041661a
commit
e72f8ceabd
@ -960,6 +960,7 @@ static int output_packet(AVFormatContext *ctx, int flush)
|
|||||||
int best_i = -1;
|
int best_i = -1;
|
||||||
int best_score = INT_MIN;
|
int best_score = INT_MIN;
|
||||||
int ignore_constraints = 0;
|
int ignore_constraints = 0;
|
||||||
|
int ignore_delay = 0;
|
||||||
int64_t scr = s->last_scr;
|
int64_t scr = s->last_scr;
|
||||||
PacketDesc *timestamp_packet;
|
PacketDesc *timestamp_packet;
|
||||||
const int64_t max_delay = av_rescale(ctx->max_delay, 90000, AV_TIME_BASE);
|
const int64_t max_delay = av_rescale(ctx->max_delay, 90000, AV_TIME_BASE);
|
||||||
@ -985,7 +986,7 @@ retry:
|
|||||||
if (space < s->packet_size && !ignore_constraints)
|
if (space < s->packet_size && !ignore_constraints)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (next_pkt && next_pkt->dts - scr > max_delay)
|
if (next_pkt && next_pkt->dts - scr > max_delay && !ignore_delay)
|
||||||
continue;
|
continue;
|
||||||
if ( stream->predecode_packet
|
if ( stream->predecode_packet
|
||||||
&& stream->predecode_packet->size > stream->buffer_index)
|
&& stream->predecode_packet->size > stream->buffer_index)
|
||||||
@ -999,6 +1000,7 @@ retry:
|
|||||||
|
|
||||||
if (best_i < 0) {
|
if (best_i < 0) {
|
||||||
int64_t best_dts = INT64_MAX;
|
int64_t best_dts = INT64_MAX;
|
||||||
|
int has_premux = 0;
|
||||||
|
|
||||||
for (i = 0; i < ctx->nb_streams; i++) {
|
for (i = 0; i < ctx->nb_streams; i++) {
|
||||||
AVStream *st = ctx->streams[i];
|
AVStream *st = ctx->streams[i];
|
||||||
@ -1006,12 +1008,12 @@ retry:
|
|||||||
PacketDesc *pkt_desc = stream->predecode_packet;
|
PacketDesc *pkt_desc = stream->predecode_packet;
|
||||||
if (pkt_desc && pkt_desc->dts < best_dts)
|
if (pkt_desc && pkt_desc->dts < best_dts)
|
||||||
best_dts = pkt_desc->dts;
|
best_dts = pkt_desc->dts;
|
||||||
|
has_premux |= !!stream->premux_packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (best_dts < INT64_MAX) {
|
||||||
av_dlog(ctx, "bumping scr, scr:%f, dts:%f\n",
|
av_dlog(ctx, "bumping scr, scr:%f, dts:%f\n",
|
||||||
scr / 90000.0, best_dts / 90000.0);
|
scr / 90000.0, best_dts / 90000.0);
|
||||||
if (best_dts == INT64_MAX)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (scr >= best_dts + 1 && !ignore_constraints) {
|
if (scr >= best_dts + 1 && !ignore_constraints) {
|
||||||
av_log(ctx, AV_LOG_ERROR,
|
av_log(ctx, AV_LOG_ERROR,
|
||||||
@ -1021,6 +1023,14 @@ retry:
|
|||||||
scr = FFMAX(best_dts + 1, scr);
|
scr = FFMAX(best_dts + 1, scr);
|
||||||
if (remove_decoded_packets(ctx, scr) < 0)
|
if (remove_decoded_packets(ctx, scr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (has_premux && flush) {
|
||||||
|
av_log(ctx, AV_LOG_ERROR,
|
||||||
|
"delay too large, ignoring ...\n");
|
||||||
|
ignore_delay = 1;
|
||||||
|
ignore_constraints = 1;
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user