胡斌

V2.0.7

2.修改在一对一布局下,有一个视频是竖屏时,对竖屏的缩放处理不正常
@@ -84,26 +84,13 @@ _one2one_same_size(one2one_same_size) @@ -84,26 +84,13 @@ _one2one_same_size(one2one_same_size)
84 84
85 if (_one2one_same_size) { 85 if (_one2one_same_size) {
86 int max_width = _nOutputWidth; 86 int max_width = _nOutputWidth;
87 - int max_height = max(_teacher_height, _student_height);  
88 - int min_width = min(_teacher_width, _student_width);  
89 - int min_height = min(_teacher_height, _student_height);  
90 87
91 - if (_teacher_width < _student_width) {  
92 - _teacher_width = _student_width;  
93 - }  
94 - else if (_student_width < _teacher_width) {  
95 - _student_width = _teacher_width;  
96 - }  
97 - if (_teacher_height < _student_height) {  
98 - _teacher_height = _student_height;  
99 - }  
100 - else if (_student_height < _teacher_height) {  
101 - _student_height = _teacher_height;  
102 - } 88 + double wh_ratio_teacher = _teacher_width / (double)_teacher_height;
  89 + double wh_ratio_student = _student_width / (double)_student_height;
103 90
104 - init_scale_context(&_sws_ctx_w_h, &_scaled_frame_w_h, min_width, min_height, max_width, max_height);  
105 - init_scale_context(&_sws_ctx_h_w, &_scaled_frame_h_w, min_height, min_width, max_height, max_width);  
106 - init_scale_context(&_sws_ctx_h_h, &_scaled_frame_h_h, min_height, min_height, max_height, max_height); 91 + double max_ratio = max(wh_ratio_teacher, wh_ratio_student);
  92 + _teacher_width = _student_width = max_width;
  93 + _teacher_height = _student_height = (int)(max_width / max_ratio + 0.5);
107 } 94 }
108 95
109 _nOutputHeight = _teacher_height + _student_height; 96 _nOutputHeight = _teacher_height + _student_height;
@@ -734,16 +721,21 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -734,16 +721,21 @@ int CAVTranscoder::open_output_file(const char *filename)
734 return 0; 721 return 0;
735 } 722 }
736 723
  724 +
  725 +
  726 +
737 int CAVTranscoder::scale_fill_one2one_teacherframe(AVFrame *pDstFrame) 727 int CAVTranscoder::scale_fill_one2one_teacherframe(AVFrame *pDstFrame)
738 { 728 {
739 if (_src_width_teacher != _teacherFrame->width || _src_height_teacher != _teacherFrame->height) {//init scale context 729 if (_src_width_teacher != _teacherFrame->width || _src_height_teacher != _teacherFrame->height) {//init scale context
  730 +
740 free_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher); 731 free_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher);
741 - if (_teacherFrame->width >= _teacherFrame->height) {  
742 - init_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher, _teacherFrame->width, _teacherFrame->height, _teacher_width, _teacher_height);  
743 - }  
744 - else {  
745 - init_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher, _teacherFrame->height, _teacherFrame->width, _teacher_width, _teacher_height);  
746 - } 732 +
  733 + int scaled_width, scaled_height;
  734 + get_scaled_dest_size(_teacherFrame, _teacher_width, _teacher_height, &scaled_width, &scaled_height);
  735 + init_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher, _teacherFrame->width, _teacherFrame->height, scaled_width, scaled_height);
  736 +
  737 + _src_width_teacher = _teacherFrame->width;
  738 + _src_height_teacher = _teacherFrame->height;
747 } 739 }
748 740
749 int h = 0; 741 int h = 0;
@@ -754,43 +746,27 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -754,43 +746,27 @@ int CAVTranscoder::open_output_file(const char *filename)
754 av_frame_free(&_teacherFrame); 746 av_frame_free(&_teacherFrame);
755 _teacherFrame = _scaled_frame_teacher; 747 _teacherFrame = _scaled_frame_teacher;
756 748
757 - if (_teacherFrame->width == _teacher_width && _teacherFrame->height == _teacher_height) {  
758 - if (_teacherFrame->pkt_dts != 90){  
759 - if (_teacher_width < _nOutputWidth) {  
760 - memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height);  
761 - memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2);  
762 - memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2);  
763 - }  
764 - fillDestFrame(pDstFrame, _teacherFrame, 0, 0); 749 + if (_teacherFrame->pkt_dts == 0 || _teacherFrame->pkt_dts == 180) {
  750 + if (_teacher_width != _teacherFrame->width || _teacher_height != _teacherFrame->height){
  751 + memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height);
  752 + memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2);
  753 + memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2);
  754 + fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacherFrame->width) / 2, (_teacher_height - _teacherFrame->height) / 2);
765 } 755 }
766 else { 756 else {
767 - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height);  
768 - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 2);  
769 - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 2);  
770 - fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0, (_teacher_width - _teacher_height) / 2, 0, _teacher_height, _teacher_height);  
771 - }  
772 - }  
773 - else if (_teacherFrame->width == _teacher_height && _teacherFrame->height == _teacher_width) {  
774 - if (_teacherFrame->pkt_dts == 90){  
775 - if (_teacher_width < _nOutputWidth) {  
776 - memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height);  
777 - memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2);  
778 - memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2);  
779 - }  
780 fillDestFrame(pDstFrame, _teacherFrame, 0, 0); 757 fillDestFrame(pDstFrame, _teacherFrame, 0, 0);
781 } 758 }
782 - else { 759 + }
  760 + else {
  761 + if (_teacher_width != _teacherFrame->height || _teacher_height != _teacherFrame->width){
783 memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height); 762 memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height);
784 memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2); 763 memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2);
785 memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2); 764 memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2);
786 - fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0, 0, (_teacher_width - _teacher_height) / 2, _teacher_height, _teacher_height); 765 + fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacherFrame->height) / 2, (_teacher_height - _teacherFrame->width) / 2);
  766 + }
  767 + else {
  768 + fillDestFrame(pDstFrame, _teacherFrame, 0, 0);
787 } 769 }
788 - }  
789 - else if (_teacherFrame->width == _teacher_height && _teacherFrame->height == _teacher_height) {  
790 - memset(pDstFrame->data[0], _blank_y, pDstFrame->linesize[0] * _teacher_height);  
791 - memset(pDstFrame->data[1], _blank_u, pDstFrame->linesize[1] * _teacher_height / 2);  
792 - memset(pDstFrame->data[2], _blank_v, pDstFrame->linesize[2] * _teacher_height / 2);  
793 - fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0);  
794 } 770 }
795 771
796 return 0; 772 return 0;
@@ -800,12 +776,14 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -800,12 +776,14 @@ int CAVTranscoder::open_output_file(const char *filename)
800 { 776 {
801 if (_src_width_student != _studentFrame->width || _src_height_student != _studentFrame->height) {//init scale context 777 if (_src_width_student != _studentFrame->width || _src_height_student != _studentFrame->height) {//init scale context
802 free_scale_context(&_sws_ctx_student, &_scaled_frame_student); 778 free_scale_context(&_sws_ctx_student, &_scaled_frame_student);
803 - if (_studentFrame->width >= _studentFrame->height) {  
804 - init_scale_context(&_sws_ctx_student, &_scaled_frame_student, _studentFrame->width, _studentFrame->height, _student_width, _student_height);  
805 - }  
806 - else {  
807 - init_scale_context(&_sws_ctx_student, &_scaled_frame_student, _studentFrame->height, _studentFrame->width, _student_width, _student_height);  
808 - } 779 +
  780 + int scaled_width, scaled_height;
  781 +
  782 + get_scaled_dest_size(_studentFrame, _student_width, _student_height, &scaled_width, &scaled_height);
  783 + init_scale_context(&_sws_ctx_student, &_scaled_frame_student, _studentFrame->width, _studentFrame->height, scaled_width, scaled_height);
  784 +
  785 + _src_width_student = _studentFrame->width;
  786 + _src_height_student = _studentFrame->height;
809 } 787 }
810 788
811 int h = 0; 789 int h = 0;
@@ -816,43 +794,27 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -816,43 +794,27 @@ int CAVTranscoder::open_output_file(const char *filename)
816 av_frame_free(&_studentFrame); 794 av_frame_free(&_studentFrame);
817 _studentFrame = _scaled_frame_student; 795 _studentFrame = _scaled_frame_student;
818 796
819 - if (_studentFrame->width == _student_width && _studentFrame->height == _student_height) {  
820 - if (_studentFrame->pkt_dts != 90){  
821 - if (_student_width < _nOutputWidth) {  
822 - memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height);  
823 - memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2 , _blank_u, pDstFrame->linesize[1] * _student_height / 2);  
824 - memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2 , _blank_v, pDstFrame->linesize[2] * _student_height / 2);  
825 - }  
826 - fillDestFrame(pDstFrame, _studentFrame, 0, y); 797 + if (_studentFrame->pkt_dts == 0 || _studentFrame->pkt_dts == 180) {
  798 + if (_teacher_width != _studentFrame->width || _teacher_height != _studentFrame->height){
  799 + memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height);
  800 + memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2);
  801 + memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2);
  802 + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _studentFrame->width) / 2, (_student_height - _studentFrame->height) / 2 + y);
827 } 803 }
828 else { 804 else {
829 - memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _student_height);  
830 - memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, _nOutputWidth * _student_height / 2);  
831 - memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, _nOutputWidth * _student_height / 2);  
832 - fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, y, (_student_width - _student_height) / 2, 0, _student_height, _student_height);  
833 - }  
834 - }  
835 - else if (_studentFrame->width == _student_height && _studentFrame->height == _student_width) {  
836 - if (_studentFrame->pkt_dts == 90){  
837 - if (_student_width < _nOutputWidth) {  
838 - memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height);  
839 - memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2);  
840 - memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2);  
841 - }  
842 fillDestFrame(pDstFrame, _studentFrame, 0, y); 805 fillDestFrame(pDstFrame, _studentFrame, 0, y);
843 } 806 }
844 - else { 807 + }
  808 + else {
  809 + if (_teacher_width != _studentFrame->height || _teacher_height != _studentFrame->width){
845 memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height); 810 memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height);
846 memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2); 811 memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2);
847 memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2); 812 memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2);
848 - fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, y, 0, (_student_width - _student_height) / 2, _student_height, _student_height); 813 + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _studentFrame->height) / 2, (_student_height - _studentFrame->width) / 2 + y);
  814 + }
  815 + else {
  816 + fillDestFrame(pDstFrame, _studentFrame, 0, y);
849 } 817 }
850 - }  
851 - else if (_studentFrame->width == _student_height && _studentFrame->height == _student_height) {  
852 - memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height);  
853 - memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2);  
854 - memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2);  
855 - fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, y);  
856 } 818 }
857 819
858 return 0; 820 return 0;
@@ -896,6 +858,34 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -896,6 +858,34 @@ int CAVTranscoder::open_output_file(const char *filename)
896 } 858 }
897 859
898 860
  861 + void CAVTranscoder::get_scaled_dest_size(AVFrame * pFrame, int dest_width, int dest_height, int* scaled_width, int* scaled_height)
  862 + {
  863 + if (pFrame->pkt_dts == 0 || pFrame->pkt_dts == 180) {
  864 + double src_wh_ratio = pFrame->width / (double)pFrame->height;
  865 + double dest_wh_ratio = dest_width / (double)dest_height;
  866 + if (src_wh_ratio > dest_wh_ratio) {
  867 + *scaled_width = dest_width;
  868 + *scaled_height =(int)( dest_width / src_wh_ratio + 0.5);
  869 + }
  870 + else {
  871 + *scaled_height = dest_height;
  872 + *scaled_width = (int)(dest_height * src_wh_ratio);
  873 + }
  874 + }
  875 + else {
  876 + double src_wh_ratio = pFrame->height / (double)pFrame->width;
  877 + double dest_wh_ratio = dest_width / (double)dest_height;
  878 + if (src_wh_ratio > dest_wh_ratio) {
  879 + *scaled_height = dest_width;
  880 + *scaled_width = (int)(dest_width / src_wh_ratio + 0.5);
  881 + }
  882 + else {
  883 + *scaled_width = dest_height;
  884 + *scaled_height = (int)(dest_height * src_wh_ratio);
  885 + }
  886 + }
  887 + }
  888 +
899 int CAVTranscoder::mix_and_output_one2one_vframe(vector<CAVDecoder *> & decoders_got_frame) 889 int CAVTranscoder::mix_and_output_one2one_vframe(vector<CAVDecoder *> & decoders_got_frame)
900 { 890 {
901 //prepare one2one base frame 891 //prepare one2one base frame
@@ -80,5 +80,6 @@ public: @@ -80,5 +80,6 @@ public:
80 private: 80 private:
81 int scale_fill_one2one_studentframe(AVFrame * pDstFrame, int y); 81 int scale_fill_one2one_studentframe(AVFrame * pDstFrame, int y);
82 int fill_one2one_student_frame(AVFrame * pDstFrame, int y); 82 int fill_one2one_student_frame(AVFrame * pDstFrame, int y);
  83 + void get_scaled_dest_size(AVFrame * pFrame, int dest_width, int dest_height, int* scaled_width, int* scaled_height);
83 }; 84 };
84 85
@@ -82,4 +82,5 @@ V2.0.6 @@ -82,4 +82,5 @@ V2.0.6
82 0 保持原有视频大小 82 0 保持原有视频大小
83 83
84 V2.0.7 84 V2.0.7
85 -1.修改bug: 在V2.0.4开放了设置视频编码参数,由于修改不完整,其中fps设置如果不是默认的参数20,会导致音视频不同步。  
  85 +1.修改bug: 在V2.0.4开放了设置视频编码参数,由于修改不完整,其中fps设置如果不是默认的参数20,会导致音视频不同步。
  86 +2.修改在一对一布局下,有一个视频是竖屏时,对竖屏的缩放处理不正常
@@ -716,7 +716,7 @@ void add_media_infos() @@ -716,7 +716,7 @@ void add_media_infos()
716 for (; it != sorted_media_with_end.end();it++){ 716 for (; it != sorted_media_with_end.end();it++){
717 if (it->m_type == mt_video) { 717 if (it->m_type == mt_video) {
718 printf("\n%2d %8.3f %s %s %4d %4d %3d", it->sorted_index, it->type_time, it->name.c_str(), it->t_type == tt_start ? "start" : "end", it->width, it->height, it->rotate); 718 printf("\n%2d %8.3f %s %s %4d %4d %3d", it->sorted_index, it->type_time, it->name.c_str(), it->t_type == tt_start ? "start" : "end", it->width, it->height, it->rotate);
719 - if (it->width > it->height) { 719 + if (it->rotate == 0 || it->rotate == 180) {
720 if (width < it->width) { 720 if (width < it->width) {
721 width = it->width; 721 width = it->width;
722 } 722 }
@@ -734,7 +734,7 @@ void add_media_infos() @@ -734,7 +734,7 @@ void add_media_infos()
734 } 734 }
735 if (it->m_role == mr_teacher) { 735 if (it->m_role == mr_teacher) {
736 has_teacher = true; 736 has_teacher = true;
737 - if (it->width > it->height) { 737 + if (it->rotate == 0 || it->rotate == 180) {
738 if (width_teacher < it->width) { 738 if (width_teacher < it->width) {
739 width_teacher = it->width; 739 width_teacher = it->width;
740 } 740 }
@@ -752,7 +752,7 @@ void add_media_infos() @@ -752,7 +752,7 @@ void add_media_infos()
752 } 752 }
753 } 753 }
754 else { 754 else {
755 - if (it->width > it->height) { 755 + if (it->rotate == 0 || it->rotate == 180) {
756 if (width_student < it->width) { 756 if (width_student < it->width) {
757 width_student = it->width; 757 width_student = it->width;
758 } 758 }
@@ -1088,7 +1088,7 @@ int load_record_info(char * record_info) @@ -1088,7 +1088,7 @@ int load_record_info(char * record_info)
1088 1088
1089 #define MIN_TIME_INTERVAL 25 1089 #define MIN_TIME_INTERVAL 25
1090 1090
1091 -int process_av_files(char * record_info, int piptype, bool one2one_same_size) 1091 +int process_av_files(char * record_info, int piptype, bool one2one_same_size, int64_t max_duration)
1092 { 1092 {
1093 time_t start, end; 1093 time_t start, end;
1094 time(&start); 1094 time(&start);
@@ -1172,6 +1172,12 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size) @@ -1172,6 +1172,12 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size)
1172 1172
1173 cur_time = (int64_t) videoTranscoder.transcode(); 1173 cur_time = (int64_t) videoTranscoder.transcode();
1174 1174
  1175 + if (cur_time >= max_duration){
  1176 + printf("\n max duration reached, stop now");
  1177 + break;
  1178 + }
  1179 +
  1180 +
1175 encode_loop_count++; 1181 encode_loop_count++;
1176 if (encode_loop_count == 1200) { 1182 if (encode_loop_count == 1200) {
1177 encode_loop_count = 0; 1183 encode_loop_count = 0;
@@ -1180,12 +1186,15 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size) @@ -1180,12 +1186,15 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size)
1180 } 1186 }
1181 1187
1182 while (!videoTranscoder.all_processed()){ 1188 while (!videoTranscoder.all_processed()){
1183 - cur_time = videoTranscoder.transcode();  
1184 - encode_loop_count++;  
1185 - if (encode_loop_count == 1200) {  
1186 - encode_loop_count = 0;  
1187 - printf("\n encoded : %d s\n", cur_time / 1000);  
1188 - } 1189 + if (cur_time >= max_duration){
  1190 + break;
  1191 + }
  1192 + cur_time = videoTranscoder.transcode();
  1193 + encode_loop_count++;
  1194 + if (encode_loop_count == 1200) {
  1195 + encode_loop_count = 0;
  1196 + printf("\n encoded : %d s\n", cur_time / 1000);
  1197 + }
1189 } 1198 }
1190 1199
1191 videoTranscoder.close(); 1200 videoTranscoder.close();
@@ -1211,6 +1220,7 @@ int main(int argc, char * argv[]) @@ -1211,6 +1220,7 @@ int main(int argc, char * argv[])
1211 1220
1212 int piptype = 0; 1221 int piptype = 0;
1213 bool one2one_same_size = true; 1222 bool one2one_same_size = true;
  1223 + int64_t max_duration = INT64_MAX;
1214 for (int i = 2; i < argc; i++){ 1224 for (int i = 2; i < argc; i++){
1215 if (!strcmp(argv[i], "-t")){ 1225 if (!strcmp(argv[i], "-t")){
1216 i++; 1226 i++;
@@ -1236,6 +1246,14 @@ int main(int argc, char * argv[]) @@ -1236,6 +1246,14 @@ int main(int argc, char * argv[])
1236 } 1246 }
1237 one2one_same_size = argv[i][0] == '1'; 1247 one2one_same_size = argv[i][0] == '1';
1238 } 1248 }
  1249 + else if (!strcmp(argv[i], "-d")){
  1250 + i++;
  1251 + if (i > argc) {
  1252 + printf("error,should be 1 or 0 after -d");
  1253 + return -2;
  1254 + }
  1255 + max_duration = atoi(argv[i]);
  1256 + }
1239 } 1257 }
1240 1258
1241 1259
@@ -1243,5 +1261,5 @@ int main(int argc, char * argv[]) @@ -1243,5 +1261,5 @@ int main(int argc, char * argv[])
1243 1261
1244 load_codec_param(); 1262 load_codec_param();
1245 1263
1246 - return process_av_files(argv[1], piptype, one2one_same_size); 1264 + return process_av_files(argv[1], piptype, one2one_same_size, max_duration);
1247 } 1265 }