From: yu.dongliang <18588496441@163.com> Date: Mon, 10 Apr 2023 10:27:51 +0000 (+0800) Subject: h264 X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=d8cc0f019917a10091e2434594430f3bde13056c;p=simplay.git h264 --- diff --git a/simp_ffmpeg_output.c b/simp_ffmpeg_output.c index 7f23298..f21e1fe 100644 --- a/simp_ffmpeg_output.c +++ b/simp_ffmpeg_output.c @@ -27,14 +27,18 @@ static int _video_init(simp_ffmpeg_t* priv) priv->vcodec_ctx->height = 1080; priv->vcodec_ctx->time_base = (AVRational){1, 25}; priv->vcodec_ctx->gop_size = 30; - priv->vcodec_ctx->max_b_frames = 2; + priv->vcodec_ctx->max_b_frames = 1; priv->vcodec_ctx->pix_fmt = AV_PIX_FMT_YUV420P; - priv->vcodec_ctx->sample_aspect_ratio = (AVRational){1, 1}; s->time_base = priv->vcodec_ctx->time_base; if (priv->fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) priv->vcodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + if (c->id == AV_CODEC_ID_H264) { + av_opt_set(priv->vcodec_ctx->priv_data, "preset", "ultrafast", 0); + av_opt_set(priv->vcodec_ctx->priv_data, "tune", "zerolatency", 0); + } + int ret = avcodec_open2(priv->vcodec_ctx, c, NULL); if (ret < 0) { scf_loge("avcodec_open2 error, ret: %d, %s\n", ret, av_err2str(ret));