video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-09-29 e878e92811a2dbfb6b4d3f7b2c357435f56e28db
add trytime
3个文件已修改
32 ■■■■■ 已修改文件
csrc/buz/recorder.cpp 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/ffmpeg/format/FormatIn.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/ffmpeg/format/FormatOut.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/buz/recorder.cpp
@@ -225,15 +225,22 @@
            int ret = mux_hevc(fp, file_path_.c_str());
            fclose(fp);
            if (ret == 0){
            if (remove(hevc_file.c_str()) != 0){
                logIt("mux hevc remove file %s failed", hevc_file.c_str());
            }
            }else{
                logIt("mux hevc to mp4 error, use raw hevc");
                file_path_ = hevc_file;
            }
            return ret;
            return 0;
        }
        static int read_buffer(void *opaque, uint8_t *buf, int buf_size){
            FILE *fp_open = (FILE*)opaque;
            if (!fp_open) logIt("mux hevc open file error");
            if(!feof(fp_open)){
                int true_size=fread(buf,1,buf_size,fp_open);
                return true_size;
@@ -250,8 +257,14 @@
                return -1;
            }
            if (in->openWithCustomIO(fp, read_buffer) < 0) {
                logIt("mux hevc open custom io error");
            int tryTime = 0;
            while (in->openWithCustomIO(fp, read_buffer) < 0) {
                usleep(10000);
                if (tryTime++ < 100){
                    logIt("mux hevc mux: %d failed open custom io %s, try again", tryTime, outfile);
                    continue;
                }
                logIt("mux hevc try %d time to open custom io, failed", tryTime);
                return -2;
            }
            if (in->open(NULL, NULL) < 0){
@@ -293,14 +306,10 @@
        void Recorder::end_writer(){
            int ret = -1;
            if (in_->IsHEVC()){
                ret = end_write_hevc();
                end_write_hevc();
            }else{
                ret = end_write_h264();
            }
            if (ret < 0){
                logIt("end write file : %s, h265: %d, failed", file_path_.c_str(), in_->IsHEVC());
                end_write_h264();
            }
            logIt("finished record : %s frames: %d", file_path_.c_str(), cur_frame);
csrc/ffmpeg/format/FormatIn.cpp
@@ -86,8 +86,7 @@
        auto err = av_probe_input_buffer(ctx_->pb, &ctx_->iformat, NULL, NULL, 0, read_io_buff_size_);
        if(err != 0){
            logIt("open with custom io prob input buffer error:%d\n", err);
            logIt("custom io failed:%s", getAVErrorDesc(err).c_str());
            logIt("open with custom io prob input buffer error:%d err: %s\n", err, getAVErrorDesc(err).c_str());
            return -1;
        }
csrc/ffmpeg/format/FormatOut.cpp
@@ -293,7 +293,7 @@
            logIt("Failed to copy context from input to output stream codec context\n");
            return false;
        }
        out_stream->codecpar->codec_tag = out_stream->codec->codec_tag = 0;
        out_stream->codecpar->codec_tag = 0;
        
        if(ctx_->oformat->flags & AVFMT_GLOBALHEADER)
            out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;