Browse Source

add log 3

DevYK 3 years ago
parent
commit
5bd51a4648

+ 1 - 0
src/opencv/image_fingerprint.cpp

@@ -57,6 +57,7 @@ int fingerprintFromFFAVFrame(FILE *file, AVFrame *frame, char buf[64]) {
         sws_scale(conversion, frame->data, frame->linesize, 0, height, &img.data, cvLinesizes);
         printf("fingerprintFromFFAVFrame -5\n");
         sws_freeContext(conversion);
+        conversion = NULL;
     } else {
         printf("sws_getContext init error .");
         return NULL;

+ 11 - 9
src/utils/video_similarity.cpp

@@ -83,13 +83,17 @@ void sig_crash(int sig) {
     fd = NULL;
 }
 
-long video_similarity_detection_init(const char *url) {
+long video_similarity_detection_init(const char *url, VideoSimilarity **vs) {
     auto *ctx = (VideoSimilarityContext *) malloc(sizeof(VideoSimilarityContext));
     if (!ctx)return -1;
     memset(ctx, 0, sizeof(VideoSimilarityContext));
-    if (url)
-        ctx->video_path = strdup(url);
-    else return -1;
+    if (url) {
+        *vs = json2VideoSimilarity(url);
+        if (!(*vs))return -1L;
+        if ((*vs)->videoPath)
+            ctx->video_path = (*vs)->videoPath;
+        else return -1L;
+    }
     return (long) ctx;
 }
 
@@ -180,7 +184,7 @@ int video_similarity_detection_close(long id) {
     auto *ctx = (VideoSimilarityContext *) id;
     LOGE("video_similarity_detection_close \n");
     if (ctx->video_path) {
-        free((void *) ctx->video_path);
+//        free((void *) ctx->video_path);
         ctx->video_path = NULL;
     }
     if (ctx->log) {
@@ -290,12 +294,10 @@ const char *get_video_similarity_list(const char *inputjson) {
     signal(SIGSEGV, sig_crash);
     if (!inputjson)return NULL;
     printf("get_video_similarity_list=%s \n", inputjson);
-    auto *vs = json2VideoSimilarity(inputjson);
-    if (!vs)return NULL;
-    long id = video_similarity_detection_init(vs->videoPath);
+    VideoSimilarity *vs = NULL;
+    long id = video_similarity_detection_init(inputjson, &vs);
     const char *ret_json = NULL;
     if (id > 0) {
-
         if (!(((VideoSimilarityContext *) id)->log)) {
             int n = strlen(((VideoSimilarityContext *) id)->video_path); //计算字符串的长度(包括'\0')
             const char *name = GetFileName(((VideoSimilarityContext *) id)->video_path, n); //把字符串及其长度传给函数

+ 1 - 1
src/utils/video_similarity.h

@@ -40,7 +40,7 @@ const char *videoSimilarity2json(VideoSimilarity *videoSimilarity);
  * @param url 视频路径
  * @return 对象 id
  */
-long video_similarity_detection_init(const char *url);
+long video_similarity_detection_init(const char *url, VideoSimilarity **pSimilarity);
 
 /**
  * 开始分析

+ 1 - 1
src/video_similarity_comparison.cpp

@@ -19,7 +19,7 @@ typedef struct VsimBean {
 } VsimBean;
 
 static void run(const char *filepath, std::vector<VideoSimilarityModel *> *list) {
-    long id = video_similarity_detection_init(filepath);
+    long id = video_similarity_detection_init(filepath, nullptr);
     if (id > 0) {
         int ret = video_similarity_detection_start(id, 0, AUDIO,
                                                    list);