⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4syncfiles.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  CHECK_AND_FREE(fromvalue);  MP4GetMetadataAlbumArtist(to, &tovalue);  MP4GetMetadataAlbumArtist(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataAlbumArtist(to);    if (fromvalue != NULL)      MP4SetMetadataAlbumArtist(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataWriter(to, &tovalue);  MP4GetMetadataWriter(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataWriter(to);    if (fromvalue != NULL)      MP4SetMetadataWriter(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataYear(to, &tovalue);  MP4GetMetadataYear(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataYear(to);    if (fromvalue != NULL)      MP4SetMetadataYear(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataAlbum(to, &tovalue);  MP4GetMetadataAlbum(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataAlbum(to);    if (fromvalue != NULL)      MP4SetMetadataAlbum(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataGenre(to, &tovalue);  MP4GetMetadataGenre(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataGenre(to);    if (fromvalue != NULL)      MP4SetMetadataGenre(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataGrouping(to, &tovalue);  MP4GetMetadataGrouping(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataGrouping(to);    if (fromvalue != NULL)      MP4SetMetadataGrouping(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataComment(to, &tovalue);  MP4GetMetadataComment(from, &fromvalue);  if (tovalue == NULL || fromvalue == NULL || strcmp(tovalue, fromvalue) != 0) {    if (tovalue != NULL)       MP4DeleteMetadataComment(to);    if (fromvalue != NULL)      MP4SetMetadataComment(to, fromvalue);  }  CHECK_AND_FREE(tovalue);  CHECK_AND_FREE(fromvalue);  MP4GetMetadataTempo(to, &tonum);  MP4GetMetadataTempo(from, &fromnum);  if (tonum != fromnum) {    MP4DeleteMetadataTempo(to);    MP4SetMetadataTempo(to, fromnum);  }  MP4GetMetadataTrack(to, &tonum, &tonum2);  MP4GetMetadataTrack(from, &fromnum, &fromnum2);  if (tonum != fromnum || tonum2 != fromnum2) {    MP4DeleteMetadataTrack(to);    MP4SetMetadataTrack(to, fromnum, fromnum2);  }  MP4GetMetadataDisk(to, &tonum, &tonum2);  MP4GetMetadataDisk(from, &fromnum, &fromnum2);  if (tonum != fromnum || tonum2 != fromnum2) {    MP4DeleteMetadataDisk(to);    MP4SetMetadataDisk(to, fromnum, fromnum2);  }  uint32_t toart, fromart;  toart = MP4GetMetadataCoverArtCount(to);  fromart = MP4GetMetadataCoverArtCount(from);  if (force  || toart != fromart) {    uint8_t *art;    uint32_t artsize;    MP4GetMetadataCoverArt(from, &art, &artsize);    if (toart != 0) MP4DeleteMetadataCoverArt(to);    if (fromart != 0) {      printf("art read %u\n", artsize);      MP4SetMetadataCoverArt(to, art, artsize);    }  }  MP4SetVerbosity(to, toverb);  MP4SetVerbosity(from, fromverb);}#if 0void transit (char *to, char *from){  do {    if (*from == ' ') {      *to++ = '\\';    }    *to++ = *from;  } while (*from++ != '\0');}#endifchar* ProgName;int main(int argc, char** argv){  const char* usageString =     "[-v [<level>]] [-force-meta] <file containing protected file names>\n";  char* difflist;  char Mp4FileName[PATH_MAX], toFileName[PATH_MAX];#if 0  MP4TrackId trackId = MP4_INVALID_TRACK_ID;  MP4SampleId sampleId = MP4_INVALID_SAMPLE_ID;#endif  u_int32_t verbosity = MP4_DETAILS_ERROR;  bool force_meta = false;  /* begin processing command line */  ProgName = argv[0];  while (true) {    int c = -1;    int option_index = 0;    static struct option long_options[] = {      { "verbose", 2, 0, 'v' },      { "version", 0, 0, 'V' },      { "force-meta", 0, 0, 'f'},      { NULL, 0, 0, 0 }    };    c = getopt_long_only(argc, argv, "v::V",			 long_options, &option_index);    if (c == -1)      break;    switch (c) {    case 'f':      force_meta = true;      break;    case 'v':      verbosity |= MP4_DETAILS_READ;      if (optarg) {	u_int32_t level;	if (sscanf(optarg, "%u", &level) == 1) {	  if (level >= 2) {	    verbosity |= MP4_DETAILS_TABLE;	  } 	  if (level >= 3) {	    verbosity |= MP4_DETAILS_SAMPLE;	  } 	  if (level >= 4) {	    verbosity = MP4_DETAILS_ALL;	  }	}      }      break;    case '?':      fprintf(stderr, "usage: %s %s", ProgName, usageString);      exit(0);    case 'V':      fprintf(stderr, "%s - %s version %s\n", 	      ProgName, MPEG4IP_PACKAGE, MPEG4IP_VERSION);      exit(0);    default:      fprintf(stderr, "%s: unknown option specified, ignoring: %c\n", 	      ProgName, c);    }  }  /* check that we have at least one non-option argument */  if ((argc - optind) < 1) {    fprintf(stderr, "usage: %s %s", ProgName, usageString);    exit(1);  }	  if (verbosity) {    fprintf(stderr, "%s version %s\n", ProgName, MPEG4IP_VERSION);  }  /* warn about extraneous non-option arguments */  /* end processing of command line */  while (optind < argc) {    difflist = argv[optind++];    FILE *lfile = fopen(difflist, "r");    while (fgets(Mp4FileName, PATH_MAX, lfile) != NULL) {      //transit(Mp4FileName, trans);      uint len = strlen(Mp4FileName);      len--;      while (isspace(Mp4FileName[len])) {	Mp4FileName[len] = '\0';	len--;      }      MP4FileHandle mp4File = MP4Read(Mp4FileName, verbosity);	      if (!mp4File) {	printf("Cannot open %s\n", Mp4FileName);      } else {	//printf("trying %s\n", Mp4FileName);	bool found = false;	struct stat statbuf;	strcpy(toFileName, Mp4FileName);	toFileName[strlen(toFileName) - 1] = 'a';	if (stat(toFileName, &statbuf) == 0 &&	    S_ISREG(statbuf.st_mode)) {	  found = true;	} else {	  char *lastslash = strrchr(toFileName, '/');	  if (lastslash == NULL) {	    lastslash = toFileName;	  } else	    lastslash++;	  if (lastslash[2] != ' ') {	    char *nextspace = lastslash;	    while (!isspace(*nextspace)) nextspace++;	    char *to = lastslash + 2;	    do {	      *to++ = *nextspace++;	    } while (*nextspace != '\0');	    *to = '\0';	  }	  for (uint ix = 1; ix < 36 && found == false; ix++) {	    lastslash[0] = (ix / 10) + '0';	    lastslash[1] = (ix % 10) + '0';	    if (stat(toFileName, &statbuf) == 0 &&		S_ISREG(statbuf.st_mode)) {	      found = true;	    }	  }	}	if (found == false) {	  printf("Couldn't find %s\n", Mp4FileName);	} else {	  MP4FileHandle toFile = MP4Read(toFileName, verbosity);	  if (!toFile) {	    printf("Cannot open %s\n", toFileName);	  } else {	    if (compare_duration(toFileName, toFile, Mp4FileName, mp4File) == false) {	      MP4Close(toFile);	      sync_duration(toFileName, mp4File);	      toFile = MP4Read(toFileName, verbosity);	    }	    if (force_meta || compare_meta(toFileName, toFile, Mp4FileName, mp4File) == false) {	      printf("need meta fixup %s\n", Mp4FileName);	      MP4Close(toFile);	      toFile = MP4Modify(toFileName, verbosity);	      if (toFile == MP4_INVALID_FILE_HANDLE) {		printf("can't open %s for modify\n", toFileName);	      }	      copy_meta(toFileName, toFile, Mp4FileName, mp4File, force_meta);	    }	    MP4Close(toFile);	  }	}	MP4Close(mp4File);      }    }    fclose(lfile);  }  return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -