胡斌

add command parameter [-t {0,1,2}] to sepcify video pip layout,

for 0,layout is decided by audio detect
for 1,using one2one layout
for 2,using one2many layout
@@ -985,7 +985,7 @@ int load_record_info(char * record_info) @@ -985,7 +985,7 @@ int load_record_info(char * record_info)
985 985
986 #define MIN_TIME_INTERVAL 25 986 #define MIN_TIME_INTERVAL 25
987 987
988 -int process_av_files(char * record_info) 988 +int process_av_files(char * record_info, int piptype)
989 { 989 {
990 time_t start, end; 990 time_t start, end;
991 time(&start); 991 time(&start);
@@ -996,7 +996,25 @@ int process_av_files(char * record_info) @@ -996,7 +996,25 @@ int process_av_files(char * record_info)
996 av_register_all(); 996 av_register_all();
997 avfilter_register_all(); 997 avfilter_register_all();
998 998
999 - CAVTranscoder videoTranscoder(max_audio==2); 999 + bool one2one = max_audio == 2;
  1000 + if (1 == piptype) {
  1001 + one2one = true;
  1002 + printf("using one2one layout\n");
  1003 + }
  1004 + else if(2 == piptype){
  1005 + one2one = false;
  1006 + printf("using one2many layout\n");
  1007 + }
  1008 + else {
  1009 + if (one2one) {
  1010 + printf("using one2one layout,because detected max %d audio\n",max_audio);
  1011 + }
  1012 + else {
  1013 + printf("using one2many layout,because detected max %d audio\n", max_audio);
  1014 + }
  1015 + }
  1016 +
  1017 + CAVTranscoder videoTranscoder(one2one);
1000 videoTranscoder.set_max_audio(max_audio); 1018 videoTranscoder.set_max_audio(max_audio);
1001 1019
1002 int64_t cur_time = 0; 1020 int64_t cur_time = 0;
@@ -1055,7 +1073,7 @@ int main(int argc, char * argv[]) @@ -1055,7 +1073,7 @@ int main(int argc, char * argv[])
1055 if (argc < 2) { 1073 if (argc < 2) {
1056 printf(" merge_pip 2.0.0\n"); 1074 printf(" merge_pip 2.0.0\n");
1057 printf(" merge video files to one pip video according to record info file,\nusage:"); 1075 printf(" merge video files to one pip video according to record info file,\nusage:");
1058 - printf("\n %s record_info_filename", argv[0]); 1076 + printf("\n %s record_info_filename [-t {0,1,2}]", argv[0]);
1059 printf("\n\n"); 1077 printf("\n\n");
1060 return -1; 1078 return -1;
1061 } 1079 }
@@ -1064,11 +1082,16 @@ int main(int argc, char * argv[]) @@ -1064,11 +1082,16 @@ int main(int argc, char * argv[])
1064 1082
1065 load_codec_param(); 1083 load_codec_param();
1066 1084
  1085 + int piptype = 0;
1067 for (int i = 2; i < argc; i++){ 1086 for (int i = 2; i < argc; i++){
1068 - if (!strcmp(argv[i], "-d")){  
1069 - out_one_video = false; 1087 + if (!strcmp(argv[i], "-t")){
  1088 + i++;
  1089 + if (i < argc) {
  1090 + printf("error,should be 0,1 or 2 after -t");
  1091 + }
  1092 + piptype = atoi(argv[i]);
1070 } 1093 }
1071 } 1094 }
1072 1095
1073 - return process_av_files(argv[1]); 1096 + return process_av_files(argv[1], piptype);
1074 } 1097 }