From d0b8204e3939e1e2d841a90ea254bc4b91309ab5 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期日, 19 一月 2020 13:32:13 +0800 Subject: [PATCH] update ffmepg gpu balance --- csrc/wrapper.cpp | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp index 1798683..3e34b2c 100644 --- a/csrc/wrapper.cpp +++ b/csrc/wrapper.cpp @@ -105,16 +105,19 @@ prop.gpu_acc_ = !cpu_; std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl())); - AVDictionary *avdic = prop.optsFormat(); int flag = -1; if (gb_){ flag = in->openGb28181(input, NULL); }else{ - flag = in->open(input, &avdic); + AVDictionary *avdic = prop.optsFormat(); + if(avdic){ + flag = in->open(input, &avdic); + av_dict_free(&avdic); + }else{ + flag = in->open(input, NULL); + } } - if(avdic){ - av_dict_free(&avdic); - } + if(flag == 0){ if(!in->findStreamInfo(NULL)){ logIt("can't find video stream\n"); @@ -154,7 +157,7 @@ stream_ = new stream(in, 3 * in->getFPS()); // stream_->AudioSwitch(audio_); - + decoder_ = new decoder(in); rec_->Load(in); @@ -256,7 +259,7 @@ void Wrapper::OpenRecorder(){ run_rec_ = true; } - + void Wrapper::BuildRecorder(const char* id, const char *output, const int64_t &fid, const int mindur, const int maxdur, const bool audio){ bool a = audio; if (gb_) a = false; @@ -323,7 +326,7 @@ cvbridge *bridge; } PicEncoder; - void *CreateEncoder(const int w, const int h, const int fps, const int br, + void *CreateEncoder(const int w, const int h, const int fps, const int br, const int pix_fmt, const int scale_flag, const int gi){ PicEncoder *e = (PicEncoder*)malloc(sizeof(PicEncoder)); -- Gitblit v1.8.0