X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=49e559679299e43bd28b0f00c1302398b33f3570;hb=451469fd1aa141b15baea06a66e2404721de1e0b;hp=42febb7ca6afd12a55486c627dbac7e4dd0d72de;hpb=c7e54628e30acbe896f92c8b8d89ae63901834ff;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 42febb7ca6a..49e55967929 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -636,7 +636,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) bsfc = bsfc->next; } - if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS) && + if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { + if( (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) && pkt->dts != AV_NOPTS_VALUE && ost->last_mux_dts != AV_NOPTS_VALUE) { @@ -657,6 +658,16 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) pkt->pts = FFMAX(pkt->pts, max); 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; @@ -1116,6 +1127,19 @@ static void do_video_stats(OutputStream *ost, int frame_size) } } +static void finish_output_stream(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + int i; + + ost->finished = ENCODER_FINISHED | MUXER_FINISHED; + + if (of->shortest) { + for (i = 0; i < of->ctx->nb_streams; i++) + output_streams[of->ost_index + i]->finished = ENCODER_FINISHED | MUXER_FINISHED; + } +} + /** * Get and encode new output from any of the filtergraphs, without causing * activity. @@ -2950,10 +2974,32 @@ static int transcode_init(void) ost->sync_ist->st->index); if (ost->stream_copy) av_log(NULL, AV_LOG_INFO, " (copy)"); - else - av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ? - input_streams[ost->source_index]->dec->name : "?", - ost->enc ? ost->enc->name : "?"); + else { + const AVCodec *in_codec = input_streams[ost->source_index]->dec; + const AVCodec *out_codec = ost->enc; + const char *decoder_name = "?"; + const char *in_codec_name = "?"; + const char *encoder_name = "?"; + const char *out_codec_name = "?"; + + if (in_codec) { + decoder_name = in_codec->name; + in_codec_name = avcodec_descriptor_get(in_codec->id)->name; + if (!strcmp(decoder_name, in_codec_name)) + decoder_name = "native"; + } + + if (out_codec) { + encoder_name = out_codec->name; + out_codec_name = avcodec_descriptor_get(out_codec->id)->name; + if (!strcmp(encoder_name, in_codec_name)) + encoder_name = "native"; + } + + av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))", + in_codec_name, decoder_name, + out_codec_name, encoder_name); + } av_log(NULL, AV_LOG_INFO, "\n"); } @@ -3282,7 +3328,7 @@ static int process_input(int file_index) if (ost->source_index == ifile->ist_index + i && (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) - close_output_stream(ost); + finish_output_stream(ost); } }