X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=652774f6cc7b4ade147abc1ca883eb1950c5de9a;hb=0a065694877e7fc37aa68d37cdfa2dee3823ad76;hp=adc3ff78006fcf87a59a084705fc84bce68632eb;hpb=014fb816d104fef876f7044c0f6876e890c93c0a;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index adc3ff78006..652774f6cc7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2678,7 +2678,7 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); ost->st->codec->codec= ost->enc_ctx->codec; } else { - ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); + ret = av_opt_set_dict(ost->st->codec, &ost->encoder_opts); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error setting up codec context options.\n"); @@ -2917,7 +2917,8 @@ static int transcode_init(void) * overhead */ if(!strcmp(oc->oformat->name, "avi")) { - if ( copy_tb<0 && av_q2d(ist->st->r_frame_rate) >= av_q2d(ist->st->avg_frame_rate) + if ( copy_tb<0 && ist->st->r_frame_rate.num + && av_q2d(ist->st->r_frame_rate) >= av_q2d(ist->st->avg_frame_rate) && 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(ist->st->time_base) && 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(dec_ctx->time_base) && av_q2d(ist->st->time_base) < 1.0/500 && av_q2d(dec_ctx->time_base) < 1.0/500 @@ -3011,6 +3012,10 @@ static int transcode_init(void) break; case AVMEDIA_TYPE_VIDEO: enc_ctx->pix_fmt = dec_ctx->pix_fmt; + enc_ctx->colorspace = dec_ctx->colorspace; + enc_ctx->color_range = dec_ctx->color_range; + enc_ctx->color_primaries = dec_ctx->color_primaries; + enc_ctx->color_trc = dec_ctx->color_trc; enc_ctx->width = dec_ctx->width; enc_ctx->height = dec_ctx->height; enc_ctx->has_b_frames = dec_ctx->has_b_frames; @@ -3058,6 +3063,11 @@ static int transcode_init(void) exit_program(1); #endif +#if CONFIG_CUVID + if (cuvid_transcode_init(ost)) + exit_program(1); +#endif + if (!ost->filter && (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO || enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) { @@ -4213,6 +4223,8 @@ static int transcode(void) } } + av_buffer_unref(&hw_device_ctx); + /* finished ! */ ret = 0;