X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=9a142947686b7dbc42c479577a23e9795ca4539f;hb=a677121cc568db7c101ebf3a797a779a983fc668;hp=a5ec3c38338eb6a02ccee07263368fcadbc55b35;hpb=4736f8115be411bb0cf24a4386d98c53553f919c;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index a5ec3c38338..9a142947686 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -694,6 +694,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) if (exit_on_error) exit_program(1); } + if (pkt->size == 0 && pkt->side_data_elems == 0) + return; if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { if (pkt->dts != AV_NOPTS_VALUE && @@ -710,6 +712,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) if( (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) && pkt->dts != AV_NOPTS_VALUE && + !(avctx->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) && ost->last_mux_dts != AV_NOPTS_VALUE) { int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); if (pkt->dts < max) { @@ -2123,8 +2126,12 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; best_effort_timestamp= av_frame_get_best_effort_timestamp(decoded_frame); - if(best_effort_timestamp != AV_NOPTS_VALUE) - ist->next_pts = ist->pts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q); + if(best_effort_timestamp != AV_NOPTS_VALUE) { + int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q); + + if (ts != AV_NOPTS_VALUE) + ist->next_pts = ist->pts = ts; + } if (debug_ts) { av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video " @@ -2543,6 +2550,8 @@ static int init_input_stream(int ist_index, char *error, int error_len) 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"); } + av_dict_set(&ist->decoder_opts, "sub_text_format", "ass", AV_DICT_DONT_OVERWRITE); + if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) av_dict_set(&ist->decoder_opts, "threads", "auto", 0); if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) { @@ -2603,6 +2612,12 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) av_dict_set(&ost->encoder_opts, "b", "128000", 0); + if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) { + ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx); + if (!ost->enc_ctx->hw_frames_ctx) + return AVERROR(ENOMEM); + } + if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { if (ret == AVERROR_EXPERIMENTAL) abort_codec_experimental(codec, 1); @@ -3194,13 +3209,6 @@ static int transcode_init(void) } } - /* open each encoder */ - for (i = 0; i < nb_output_streams; i++) { - ret = init_output_stream(output_streams[i], error, sizeof(error)); - if (ret < 0) - goto dump_format; - } - /* init input streams */ for (i = 0; i < nb_input_streams; i++) if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { @@ -3211,6 +3219,13 @@ static int transcode_init(void) goto dump_format; } + /* open each encoder */ + for (i = 0; i < nb_output_streams; i++) { + ret = init_output_stream(output_streams[i], error, sizeof(error)); + if (ret < 0) + goto dump_format; + } + /* discard unused programs */ for (i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i];