胡斌

modify the pip layout,if both teacher and student has video ,teacher at lop,and student at bottom

@@ -105,13 +105,16 @@ void get_config_path(){ @@ -105,13 +105,16 @@ void get_config_path(){
105 const char * default_vcodec_param = "-vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr"; 105 const char * default_vcodec_param = "-vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr";
106 const char * default_acodec_param = "-acodec copy"; 106 const char * default_acodec_param = "-acodec copy";
107 const char * default_av_codec_param = "-acodec aac -vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr"; 107 const char * default_av_codec_param = "-acodec aac -vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr";
108 -const char * default_pip_param = "-filter_complex \"[1:v]scale=w=96:h=72:force_original_aspect_ratio=decrease[b];[0:v][b]overlay=x=0:y=0\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2,volume=1"; 108 +//const char * default_pip_param = "-filter_complex \"[1:v]scale=w=96:h=72:force_original_aspect_ratio=decrease[b];[0:v][b]overlay=x=0:y=0\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2,volume=1";
  109 +const char * default_pip_param = "-filter_complex \"[1:v]scale=w=320:h=240:force_original_aspect_ratio=decrease[b];[0:v]scale=w=320:h=240,pad=320:480:0:0:#165a82[c],[c][b]overlay=x=0:y=240\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2,volume=1";
  110 +const char * default_pip1_param = " -filter_complex \"scale=w=320:h=240,pad=320:480:0:0:#165a82\" -vcodec libx264 -level 3.1 -preset veryfast -g 100 -r 20 -bf 0 -vsync cfr -acodec copy";
109 111
110 112
111 char av_codec_param[1024]; 113 char av_codec_param[1024];
112 char vcodec_param[1024]; 114 char vcodec_param[1024];
113 char acodec_param[1024]; 115 char acodec_param[1024];
114 char pip_param[1024]; 116 char pip_param[1024];
  117 +char pip1_param[1024];
115 118
116 bool first_time_set = false; 119 bool first_time_set = false;
117 float start_time = 0.0f; 120 float start_time = 0.0f;
@@ -199,6 +202,20 @@ void split_av(const char * mediafile, float start, float duration, char * destfi @@ -199,6 +202,20 @@ void split_av(const char * mediafile, float start, float duration, char * destfi
199 run_shell_cmd(buf); 202 run_shell_cmd(buf);
200 } 203 }
201 204
  205 +void split_av_for_1pip(const char * mediafile, float start, float duration, char * destfile)
  206 +{
  207 + char buf[2048];
  208 + sprintf(buf, "ffmpeg -y -i %s -ss %.3f -t %.3f %s %s", mediafile, start, duration, pip1_param, destfile);
  209 + run_shell_cmd(buf);
  210 +}
  211 +
  212 +void transcode_to_1pip(const char * mediafile, char * destfile)
  213 +{
  214 + char buf[2048];
  215 + sprintf(buf, "ffmpeg -y -i %s %s %s", mediafile, pip1_param, destfile);
  216 + run_shell_cmd(buf);
  217 +}
  218 +
202 void get_video_first_frame_jpeg(const char * video, const char * destfile) 219 void get_video_first_frame_jpeg(const char * video, const char * destfile)
203 { 220 {
204 char buf[2048]; 221 char buf[2048];
@@ -766,11 +783,13 @@ int transcode_file(vector<media_info> files) @@ -766,11 +783,13 @@ int transcode_file(vector<media_info> files)
766 783
767 if (video.type_time - video.start_time > 0.10 || video_end.end_time - video_end.type_time > 0.10) { 784 if (video.type_time - video.start_time > 0.10 || video_end.end_time - video_end.type_time > 0.10) {
768 sprintf(video_file, "%d_%s", nf, video.name.c_str()); 785 sprintf(video_file, "%d_%s", nf, video.name.c_str());
769 - split_av(video.name.c_str(), video.type_time - video.start_time, video_end.type_time - video.type_time, video_file); 786 + split_av_for_1pip(video.name.c_str(), video.type_time - video.start_time, video_end.type_time - video.type_time, video_file);
770 tmp_files.push_back(video_file); 787 tmp_files.push_back(video_file);
771 } 788 }
772 else{ 789 else{
773 - strcpy(video_file, video.name.c_str()); 790 + sprintf(video_file, "%d_%s", nf, video.name.c_str());
  791 + transcode_to_1pip(video.name.c_str(), video_file);
  792 + tmp_files.push_back(video_file);
774 } 793 }
775 794
776 merged_files.push_back(video_file); 795 merged_files.push_back(video_file);
@@ -1429,6 +1448,7 @@ void load_codec_param() @@ -1429,6 +1448,7 @@ void load_codec_param()
1429 strcpy(vcodec_param, default_vcodec_param); 1448 strcpy(vcodec_param, default_vcodec_param);
1430 strcpy(av_codec_param, default_av_codec_param); 1449 strcpy(av_codec_param, default_av_codec_param);
1431 strcpy(pip_param, default_pip_param); 1450 strcpy(pip_param, default_pip_param);
  1451 + strcpy(pip1_param, default_pip1_param);
1432 1452
1433 char cfgfile[1024]; 1453 char cfgfile[1024];
1434 1454
@@ -1462,9 +1482,15 @@ void load_codec_param() @@ -1462,9 +1482,15 @@ void load_codec_param()
1462 str[0] = 0; 1482 str[0] = 0;
1463 if (fin.getline(str, LINE_LENGTH)) 1483 if (fin.getline(str, LINE_LENGTH))
1464 { 1484 {
1465 - printf("load av codec from %s: %s\n", cfgfile, str); 1485 + printf("load pip codec from %s: %s\n", cfgfile, str);
1466 strcpy(pip_param, str); 1486 strcpy(pip_param, str);
1467 } 1487 }
  1488 + str[0] = 0;
  1489 + if (fin.getline(str, LINE_LENGTH))
  1490 + {
  1491 + printf("load pip1 codec from %s: %s\n", cfgfile, str);
  1492 + strcpy(pip1_param, str);
  1493 + }
1468 } 1494 }
1469 1495
1470 void get_outinfo_file_name(char * input1 , char * input2) 1496 void get_outinfo_file_name(char * input1 , char * input2)