X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=40d929dac2316e19ac6329de501b18734baf1144;hb=fbeb3fa999e8712af35f1d898ca0b0cbab707556;hp=8c288ae366eddd7a708c0af9c5a7648810760c24;hpb=251f9dcf225b2aac2181da3d7e05413483e1be74;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 8c288ae366e..40d929dac23 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); } @@ -1338,6 +1342,7 @@ static void print_final_stats(int64_t total_size) uint64_t data_size = 0; float percent = -1.0; int i, j; + int pass1_used = 1; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -1349,6 +1354,9 @@ static void print_final_stats(int64_t total_size) } extra_size += ost->enc_ctx->extradata_size; data_size += ost->data_size; + if ( (ost->enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) + != CODEC_FLAG_PASS1) + pass1_used = 0; } if (data_size && total_size>0 && total_size >= data_size) @@ -1435,7 +1443,12 @@ static void print_final_stats(int64_t total_size) total_packets, total_size); } if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){ - av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)\n"); + av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded "); + if (pass1_used) { + av_log(NULL, AV_LOG_WARNING, "\n"); + } else { + av_log(NULL, AV_LOG_WARNING, "(check -ss / -t / -frames parameters if used)\n"); + } } } @@ -2753,9 +2766,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 +2831,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 +2867,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 +2904,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 +2960,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 +3358,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)); } } }