X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=da3ab911f121cb21d5870162d59137661fc3f1a7;hb=8ce564ea280b61d21eebf8a2fd741f792ce81638;hp=8c288ae366eddd7a708c0af9c5a7648810760c24;hpb=0ba65c9f795a1d3ad842f6d3179472e35c73541c;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 8c288ae366e..da3ab911f12 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1104,6 +1104,10 @@ static void do_video_out(AVFormatContext *s, } ost->forced_keyframes_expr_const_values[FKF_N] += 1; + } else if ( ost->forced_keyframes + && !strncmp(ost->forced_keyframes, "source", 6) + && in_picture->key_frame==1) { + forced_keyframe = 1; } if (forced_keyframe) { @@ -1266,7 +1270,7 @@ static int reap_filters(int flush) if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_WARNING, "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); - } else if (flush) { + } else if (flush && ret == AVERROR_EOF) { if (filter->inputs[0]->type == AVMEDIA_TYPE_VIDEO) do_video_out(of->ctx, ost, NULL, AV_NOPTS_VALUE); } @@ -2753,9 +2757,13 @@ static int transcode_init(void) if (!ost->st->side_data) return AVERROR(ENOMEM); + ost->st->nb_side_data = 0; for (j = 0; j < ist->st->nb_side_data; j++) { const AVPacketSideData *sd_src = &ist->st->side_data[j]; - AVPacketSideData *sd_dst = &ost->st->side_data[j]; + AVPacketSideData *sd_dst = &ost->st->side_data[ost->st->nb_side_data]; + + if (ost->rotate_overridden && sd_src->type == AV_PKT_DATA_DISPLAYMATRIX) + continue; sd_dst->data = av_malloc(sd_src->size); if (!sd_dst->data) @@ -2814,6 +2822,7 @@ static int transcode_init(void) enc_ctx->width = dec_ctx->width; enc_ctx->height = dec_ctx->height; break; + case AVMEDIA_TYPE_UNKNOWN: case AVMEDIA_TYPE_DATA: case AVMEDIA_TYPE_ATTACHMENT: break; @@ -2849,7 +2858,7 @@ static int transcode_init(void) } if (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { - if (ost->filter && !ost->frame_rate.num) + if (!ost->frame_rate.num) ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter); if (ist && !ost->frame_rate.num) ost->frame_rate = ist->framerate; @@ -2886,7 +2895,7 @@ static int transcode_init(void) break; case AVMEDIA_TYPE_VIDEO: enc_ctx->time_base = av_inv_q(ost->frame_rate); - if (ost->filter && !(enc_ctx->time_base.num && enc_ctx->time_base.den)) + if (!(enc_ctx->time_base.num && enc_ctx->time_base.den)) enc_ctx->time_base = ost->filter->filter->inputs[0]->time_base; if ( av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){ @@ -2942,7 +2951,10 @@ static int transcode_init(void) ost->forced_keyframes_expr_const_values[FKF_N_FORCED] = 0; ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = NAN; ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = NAN; - } else { + + // Don't parse the 'forced_keyframes' in case of 'keep-source-keyframes', + // parse it only for static kf timings + } else if(strncmp(ost->forced_keyframes, "source", 6)) { parse_forced_key_frames(ost->forced_keyframes, ost, ost->enc_ctx); } } @@ -3337,6 +3349,8 @@ static int check_keyboard_interaction(int64_t cur_time) ret = AVERROR_PATCHWELCOME; } else { ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time); + if (ret < 0) + fprintf(stderr, "Queing command failed with error %s\n", av_err2str(ret)); } } }