summaryrefslogtreecommitdiff
path: root/libavformat/mpegenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-01 16:47:36 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-01 16:47:36 +0100
commite72f8ceabde3daa673d7c46bd1d13bf9594e2c40 (patch)
treef0e44f36bac6a78462b7c6490e4973177590223c /libavformat/mpegenc.c
parent2b4041661a41f92fdcde492e30b0fa4dc1d77676 (diff)
avformat/mpegenc: Ignore max_delay if no other options remain
Fixes assertion failure Fixes Ticket4335 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mpegenc.c')
-rw-r--r--libavformat/mpegenc.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 9cee9674a0..b1b59edc04 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -960,6 +960,7 @@ static int output_packet(AVFormatContext *ctx, int flush)
int best_i = -1;
int best_score = INT_MIN;
int ignore_constraints = 0;
+ int ignore_delay = 0;
int64_t scr = s->last_scr;
PacketDesc *timestamp_packet;
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)
continue;
- if (next_pkt && next_pkt->dts - scr > max_delay)
+ if (next_pkt && next_pkt->dts - scr > max_delay && !ignore_delay)
continue;
if ( stream->predecode_packet
&& stream->predecode_packet->size > stream->buffer_index)
@@ -999,6 +1000,7 @@ retry:
if (best_i < 0) {
int64_t best_dts = INT64_MAX;
+ int has_premux = 0;
for (i = 0; i < ctx->nb_streams; i++) {
AVStream *st = ctx->streams[i];
@@ -1006,21 +1008,29 @@ retry:
PacketDesc *pkt_desc = stream->predecode_packet;
if (pkt_desc && pkt_desc->dts < best_dts)
best_dts = pkt_desc->dts;
+ has_premux |= !!stream->premux_packet;
}
- av_dlog(ctx, "bumping scr, scr:%f, dts:%f\n",
- scr / 90000.0, best_dts / 90000.0);
- if (best_dts == INT64_MAX)
- return 0;
+ if (best_dts < INT64_MAX) {
+ av_dlog(ctx, "bumping scr, scr:%f, dts:%f\n",
+ scr / 90000.0, best_dts / 90000.0);
- if (scr >= best_dts + 1 && !ignore_constraints) {
+ if (scr >= best_dts + 1 && !ignore_constraints) {
+ av_log(ctx, AV_LOG_ERROR,
+ "packet too large, ignoring buffer limits to mux it\n");
+ ignore_constraints = 1;
+ }
+ scr = FFMAX(best_dts + 1, scr);
+ if (remove_decoded_packets(ctx, scr) < 0)
+ return -1;
+ } else if (has_premux && flush) {
av_log(ctx, AV_LOG_ERROR,
- "packet too large, ignoring buffer limits to mux it\n");
+ "delay too large, ignoring ...\n");
+ ignore_delay = 1;
ignore_constraints = 1;
- }
- scr = FFMAX(best_dts + 1, scr);
- if (remove_decoded_packets(ctx, scr) < 0)
- return -1;
+ } else
+ return 0;
+
goto retry;
}