胡斌

add silence.aac to support for the recording file having video only

set version to 1.0.4
This file is too large to display.
@@ -167,6 +167,13 @@ void merge_audio_pic(fileinfo audio, const char * picfile, const char * destfile @@ -167,6 +167,13 @@ void merge_audio_pic(fileinfo audio, const char * picfile, const char * destfile
167 run_shell_cmd(buf); 167 run_shell_cmd(buf);
168 } 168 }
169 169
  170 +void merge_video_silence(fileinfo video, const char * aacfile, const char * destfile)
  171 +{
  172 + char buf[2048];
  173 + sprintf(buf, "ffmpeg -y -i %s -i %s -shortest %s %s %s", aacfile, video.name.c_str(), acodec_param, vcodec_param, destfile);
  174 + run_shell_cmd(buf);
  175 +}
  176 +
170 void megre_audio_video(fileinfo audio, int nf, fileinfo video, const char * destfile) 177 void megre_audio_video(fileinfo audio, int nf, fileinfo video, const char * destfile)
171 { 178 {
172 char buf[2048]; 179 char buf[2048];
@@ -332,14 +339,18 @@ int process_files(const char * output_dest_file) @@ -332,14 +339,18 @@ int process_files(const char * output_dest_file)
332 int nf = 0; 339 int nf = 0;
333 char destfile[1024]; 340 char destfile[1024];
334 char blank_pic_file[1024]; 341 char blank_pic_file[1024];
  342 + char silence_aac_file[1024];
335 343
336 strcpy(blank_pic_file, cfg_path); 344 strcpy(blank_pic_file, cfg_path);
337 strcat(blank_pic_file, "blank.jpg"); 345 strcat(blank_pic_file, "blank.jpg");
338 346
  347 + strcpy(silence_aac_file, cfg_path);
  348 + strcat(silence_aac_file, "silence.aac");
  349 +
339 get_duration_from_video_file(); 350 get_duration_from_video_file();
340 351
341 if (filesvideo.size()) {//has video files 352 if (filesvideo.size()) {//has video files
342 - 353 + if (filesaudio.size()){
343 for (int i = 0; i < filesaudio.size(); i++){ // 354 for (int i = 0; i < filesaudio.size(); i++){ //
344 fileinfo audio = filesaudio[i]; 355 fileinfo audio = filesaudio[i];
345 float audio_start = audio.start_time; 356 float audio_start = audio.start_time;
@@ -436,6 +447,22 @@ int process_files(const char * output_dest_file) @@ -436,6 +447,22 @@ int process_files(const char * output_dest_file)
436 } 447 }
437 } 448 }
438 } 449 }
  450 + else{//only video
  451 + if (filesvideo.size() == 1){
  452 + fileinfo video = filesvideo[0];
  453 + merge_video_silence(video, silence_aac_file, "dest.ts");
  454 + return 0;
  455 + }
  456 +
  457 + for (int i = 0; i < filesvideo.size(); i++){
  458 + fileinfo video = filesvideo[i];
  459 + sprintf(destfile, "%d.ts", nf);
  460 + merge_video_silence(video, silence_aac_file, destfile);
  461 + merged_files.push_back(destfile);
  462 + nf++;
  463 + }
  464 + }
  465 + }
439 else {//only audio 466 else {//only audio
440 467
441 if (filesaudio.size() == 1){ 468 if (filesaudio.size() == 1){
@@ -526,7 +553,7 @@ void load_codec_param() @@ -526,7 +553,7 @@ void load_codec_param()
526 int main(int argc, char * argv[]) 553 int main(int argc, char * argv[])
527 { 554 {
528 if (argc < 2) { 555 if (argc < 2) {
529 - printf(" merge_av 1.0.3\n"); 556 + printf(" merge_av 1.0.4\n");
530 printf(" run ffmpeg to merge audio and video files according to the record info file,\nusage:"); 557 printf(" run ffmpeg to merge audio and video files according to the record info file,\nusage:");
531 printf("\n %s record_info_filename [-p] [-k]", argv[0]); 558 printf("\n %s record_info_filename [-p] [-k]", argv[0]);
532 printf("\n -p :only print the command,don't run ffmpeg"); 559 printf("\n -p :only print the command,don't run ffmpeg");
  1 +0.000 750351447_20171221092557104.webm create
  2 +0.001 750351447_20171221092557104.webm info width=240 height=180 rotation=0
  3 +752.813 750351447_20171221092557104.webm close