X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=47a414455b844eafceb84d50595151ffb6cdb9b5;hb=e113692c899f6d0b9e9f4307865d3c0a030fa20c;hp=fa907b4c45d309debdb19159e20794d518776759;hpb=ad207f1119d961bb83177765226ee8f3b80e369f;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index fa907b4c45d..47a414455b8 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -590,6 +590,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) AVCodecContext *avctx = ost->st->codec; int ret; + if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { + ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (ost->st->codec->extradata) { + memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size); + ost->st->codec->extradata_size = ost->enc_ctx->extradata_size; + } + } + if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) || (avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) pkt->pts = pkt->dts = AV_NOPTS_VALUE; @@ -651,6 +659,17 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) } if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { + if (pkt->dts != AV_NOPTS_VALUE && + pkt->pts != AV_NOPTS_VALUE && + pkt->dts > pkt->pts) { + av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", + pkt->dts, pkt->pts, + ost->file_index, ost->st->index); + pkt->pts = + pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 + - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) + - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); + } if( (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) && pkt->dts != AV_NOPTS_VALUE && @@ -673,15 +692,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) pkt->dts = max; } } - if (pkt->dts != AV_NOPTS_VALUE && - pkt->pts != AV_NOPTS_VALUE && - pkt->dts > pkt->pts) { - av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d\n", - pkt->dts, pkt->pts, - ost->file_index, ost->st->index); - pkt->pts = AV_NOPTS_VALUE; - pkt->dts = AV_NOPTS_VALUE; - } } ost->last_mux_dts = pkt->dts; @@ -1813,18 +1823,10 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) for (i = 0; i < nb_filtergraphs; i++) if (ist_in_filtergraph(filtergraphs[i], ist)) { FilterGraph *fg = filtergraphs[i]; - int j; if (configure_filtergraph(fg) < 0) { av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); exit_program(1); } - for (j = 0; j < fg->nb_outputs; j++) { - OutputStream *ost = fg->outputs[j]->ost; - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) - av_buffersink_set_frame_size(ost->filter->filter, - ost->enc_ctx->frame_size); - } } } @@ -2297,8 +2299,12 @@ static int init_input_stream(int ist_index, char *error, int error_len) ist->dec_ctx->thread_safe_callbacks = 1; av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0); - if(ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE) - av_dict_set(&ist->decoder_opts, "compute_edt", "1", 0); + if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE && + (ist->decoding_needed & DECODING_FOR_OST)) { + av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); + if (ist->decoding_needed & DECODING_FOR_FILTER) + av_log(NULL, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n"); + } if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) av_dict_set(&ist->decoder_opts, "threads", "auto", 0); @@ -2678,7 +2684,7 @@ static int transcode_init(void) } if (ist) - ist->decoding_needed++; + ist->decoding_needed |= DECODING_FOR_OST; ost->encoding_needed = 1; set_encoder_id(output_files[ost->file_index], ost); @@ -3433,7 +3439,7 @@ static int process_input(int file_index) } /* add the stream-global side data to the first packet */ - if (ist->nb_packets == 1) + if (ist->nb_packets == 1) { if (ist->st->nb_side_data) av_packet_split_side_data(&pkt); for (i = 0; i < ist->st->nb_side_data; i++) { @@ -3449,6 +3455,7 @@ static int process_input(int file_index) memcpy(dst_data, src_sd->data, src_sd->size); } + } if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);