V2.0.8
1.修改在一对一布局下,有学生或老师视频需要缩放时,如果学生或老师有多个段,会出现程序异常 2.修改在一对一布局下,不需要缩放时,学生视频如果宽度小于输出视频宽度,输出视频有部分背景花屏
正在显示
3 个修改的文件
包含
58 行增加
和
40 行删除
| @@ -722,29 +722,29 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -722,29 +722,29 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 722 | } | 722 | } |
| 723 | 723 | ||
| 724 | 724 | ||
| 725 | - | ||
| 726 | - | ||
| 727 | int CAVTranscoder::scale_fill_one2one_teacherframe(AVFrame *pDstFrame) | 725 | int CAVTranscoder::scale_fill_one2one_teacherframe(AVFrame *pDstFrame) |
| 728 | { | 726 | { |
| 729 | - if (_src_width_teacher != _teacherFrame->width || _src_height_teacher != _teacherFrame->height) {//init scale context | 727 | + if (_scaled_frame_teacher != _teacherFrame) { |
| 728 | + if (_src_width_teacher != _teacherFrame->width || _src_height_teacher != _teacherFrame->height) {//init scale context | ||
| 730 | 729 | ||
| 731 | - free_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher); | 730 | + free_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher); |
| 732 | 731 | ||
| 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); | 732 | + int scaled_width, scaled_height; |
| 733 | + get_scaled_dest_size(_teacherFrame, _teacher_width, _teacher_height, &scaled_width, &scaled_height); | ||
| 734 | + init_scale_context(&_sws_ctx_teacher, &_scaled_frame_teacher, _teacherFrame->width, _teacherFrame->height, scaled_width, scaled_height); | ||
| 736 | 735 | ||
| 737 | - _src_width_teacher = _teacherFrame->width; | ||
| 738 | - _src_height_teacher = _teacherFrame->height; | ||
| 739 | - } | 736 | + _src_width_teacher = _teacherFrame->width; |
| 737 | + _src_height_teacher = _teacherFrame->height; | ||
| 738 | + } | ||
| 740 | 739 | ||
| 741 | - int h = 0; | ||
| 742 | - h = sws_scale(_sws_ctx_teacher, _teacherFrame->data, _teacherFrame->linesize, 0, _teacherFrame->height, | ||
| 743 | - _scaled_frame_teacher->data, _scaled_frame_teacher->linesize); | ||
| 744 | - _scaled_frame_teacher->pkt_dts = _teacherFrame->pkt_dts;//pass rotation | 740 | + int h = 0; |
| 741 | + h = sws_scale(_sws_ctx_teacher, _teacherFrame->data, _teacherFrame->linesize, 0, _teacherFrame->height, | ||
| 742 | + _scaled_frame_teacher->data, _scaled_frame_teacher->linesize); | ||
| 743 | + _scaled_frame_teacher->pkt_dts = _teacherFrame->pkt_dts;//pass rotation | ||
| 745 | 744 | ||
| 746 | - av_frame_free(&_teacherFrame); | ||
| 747 | - _teacherFrame = _scaled_frame_teacher; | 745 | + av_frame_free(&_teacherFrame); |
| 746 | + _teacherFrame = _scaled_frame_teacher; | ||
| 747 | + } | ||
| 748 | 748 | ||
| 749 | if (_teacherFrame->pkt_dts == 0 || _teacherFrame->pkt_dts == 180) { | 749 | if (_teacherFrame->pkt_dts == 0 || _teacherFrame->pkt_dts == 180) { |
| 750 | if (_teacher_width != _teacherFrame->width || _teacher_height != _teacherFrame->height){ | 750 | if (_teacher_width != _teacherFrame->width || _teacher_height != _teacherFrame->height){ |
| @@ -774,25 +774,27 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -774,25 +774,27 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 774 | 774 | ||
| 775 | int CAVTranscoder::scale_fill_one2one_studentframe(AVFrame * pDstFrame, int y) | 775 | int CAVTranscoder::scale_fill_one2one_studentframe(AVFrame * pDstFrame, int y) |
| 776 | { | 776 | { |
| 777 | - if (_src_width_student != _studentFrame->width || _src_height_student != _studentFrame->height) {//init scale context | ||
| 778 | - free_scale_context(&_sws_ctx_student, &_scaled_frame_student); | 777 | + if (_scaled_frame_student != _studentFrame) { |
| 778 | + if (_src_width_student != _studentFrame->width || _src_height_student != _studentFrame->height) {//init scale context | ||
| 779 | + free_scale_context(&_sws_ctx_student, &_scaled_frame_student); | ||
| 779 | 780 | ||
| 780 | - int scaled_width, scaled_height; | 781 | + int scaled_width, scaled_height; |
| 781 | 782 | ||
| 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); | 783 | + get_scaled_dest_size(_studentFrame, _student_width, _student_height, &scaled_width, &scaled_height); |
| 784 | + init_scale_context(&_sws_ctx_student, &_scaled_frame_student, _studentFrame->width, _studentFrame->height, scaled_width, scaled_height); | ||
| 784 | 785 | ||
| 785 | - _src_width_student = _studentFrame->width; | ||
| 786 | - _src_height_student = _studentFrame->height; | ||
| 787 | - } | 786 | + _src_width_student = _studentFrame->width; |
| 787 | + _src_height_student = _studentFrame->height; | ||
| 788 | + } | ||
| 788 | 789 | ||
| 789 | - int h = 0; | ||
| 790 | - h = sws_scale(_sws_ctx_student, _studentFrame->data, _studentFrame->linesize, 0, _studentFrame->height, | ||
| 791 | - _scaled_frame_student->data, _scaled_frame_student->linesize); | ||
| 792 | - _scaled_frame_student->pkt_dts = _studentFrame->pkt_dts;//pass rotation | 790 | + int h = 0; |
| 791 | + h = sws_scale(_sws_ctx_student, _studentFrame->data, _studentFrame->linesize, 0, _studentFrame->height, | ||
| 792 | + _scaled_frame_student->data, _scaled_frame_student->linesize); | ||
| 793 | + _scaled_frame_student->pkt_dts = _studentFrame->pkt_dts;//pass rotation | ||
| 793 | 794 | ||
| 794 | - av_frame_free(&_studentFrame); | ||
| 795 | - _studentFrame = _scaled_frame_student; | 795 | + av_frame_free(&_studentFrame); |
| 796 | + _studentFrame = _scaled_frame_student; | ||
| 797 | + } | ||
| 796 | 798 | ||
| 797 | if (_studentFrame->pkt_dts == 0 || _studentFrame->pkt_dts == 180) { | 799 | if (_studentFrame->pkt_dts == 0 || _studentFrame->pkt_dts == 180) { |
| 798 | if (_teacher_width != _studentFrame->width || _teacher_height != _studentFrame->height){ | 800 | if (_teacher_width != _studentFrame->width || _teacher_height != _studentFrame->height){ |
| @@ -823,6 +825,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -823,6 +825,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 823 | 825 | ||
| 824 | int CAVTranscoder::fill_one2one_student_frame(AVFrame * pDstFrame, int y) | 826 | int CAVTranscoder::fill_one2one_student_frame(AVFrame * pDstFrame, int y) |
| 825 | { | 827 | { |
| 828 | + /* | ||
| 826 | if (_studentFrame->width == _student_width && _studentFrame->height == _student_height) { | 829 | if (_studentFrame->width == _student_width && _studentFrame->height == _student_height) { |
| 827 | if (_studentFrame->pkt_dts != 90){ | 830 | if (_studentFrame->pkt_dts != 90){ |
| 828 | fillDestFrame(pDstFrame, _studentFrame, 0, y); | 831 | fillDestFrame(pDstFrame, _studentFrame, 0, y); |
| @@ -842,18 +845,29 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -842,18 +845,29 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 842 | else if (_studentFrame->width == _student_height && _studentFrame->height == _student_height) { | 845 | else if (_studentFrame->width == _student_height && _studentFrame->height == _student_height) { |
| 843 | fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, y); | 846 | fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, y); |
| 844 | } | 847 | } |
| 845 | - else { | 848 | + else {*/ |
| 846 | if (_one2one_same_size){ | 849 | if (_one2one_same_size){ |
| 847 | scale_fill_one2one_studentframe(pDstFrame, y); | 850 | scale_fill_one2one_studentframe(pDstFrame, y); |
| 848 | } | 851 | } |
| 849 | else { | 852 | else { |
| 850 | - //printf("\nresolution: %dx%d unexpected!", _studentFrame->width, _studentFrame->height); | ||
| 851 | - memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _teacher_height); | ||
| 852 | - memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _teacher_height / 2); | ||
| 853 | - memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] /2 , _blank_v, pDstFrame->linesize[2] * _teacher_height / 2); | ||
| 854 | - fillDestFrame(pDstFrame, _studentFrame, 0, y); | ||
| 855 | - } | ||
| 856 | - } | 853 | + if (_studentFrame->pkt_dts == 0 || _studentFrame->pkt_dts == 180) { |
| 854 | + if (_studentFrame->width < _nOutputWidth || _studentFrame->height < _nOutputHeight - y) { | ||
| 855 | + memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height); | ||
| 856 | + memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2); | ||
| 857 | + memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2); | ||
| 858 | + } | ||
| 859 | + fillDestFrame(pDstFrame, _studentFrame, 0, y); | ||
| 860 | + } | ||
| 861 | + else { | ||
| 862 | + if (_studentFrame->height < _nOutputWidth || _studentFrame->width < _nOutputHeight - y) { | ||
| 863 | + memset(pDstFrame->data[0] + y * pDstFrame->linesize[0], _blank_y, pDstFrame->linesize[0] * _student_height); | ||
| 864 | + memset(pDstFrame->data[1] + y * pDstFrame->linesize[1] / 2, _blank_u, pDstFrame->linesize[1] * _student_height / 2); | ||
| 865 | + memset(pDstFrame->data[2] + y * pDstFrame->linesize[2] / 2, _blank_v, pDstFrame->linesize[2] * _student_height / 2); | ||
| 866 | + } | ||
| 867 | + fillDestFrame(pDstFrame, _studentFrame, 0, y); | ||
| 868 | + } | ||
| 869 | + } | ||
| 870 | + //} | ||
| 857 | return 0; | 871 | return 0; |
| 858 | } | 872 | } |
| 859 | 873 |
| @@ -83,4 +83,8 @@ V2.0.6 | @@ -83,4 +83,8 @@ V2.0.6 | ||
| 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.修改在一对一布局下,有一个视频是竖屏时,对竖屏的缩放处理不正常 | ||
| 86 | +2.修改在一对一布局下,有一个视频是竖屏时,对竖屏的缩放处理不正常 | ||
| 87 | + | ||
| 88 | +V2.0.8 | ||
| 89 | +1.修改在一对一布局下,有学生或老师视频需要缩放时,如果学生或老师有多个段,会出现程序异常 | ||
| 90 | +2.修改在一对一布局下,不需要缩放时,学生视频如果宽度小于输出视频宽度,输出视频有部分背景花屏 |
| @@ -1211,7 +1211,7 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size, in | @@ -1211,7 +1211,7 @@ int process_av_files(char * record_info, int piptype, bool one2one_same_size, in | ||
| 1211 | int main(int argc, char * argv[]) | 1211 | int main(int argc, char * argv[]) |
| 1212 | { | 1212 | { |
| 1213 | if (argc < 2) { | 1213 | if (argc < 2) { |
| 1214 | - printf(" merge_pip 2.0.7\n"); | 1214 | + printf(" merge_pip 2.0.8\n"); |
| 1215 | printf(" merge video files to one pip video according to record info file,\nusage:"); | 1215 | printf(" merge video files to one pip video according to record info file,\nusage:"); |
| 1216 | printf("\n %s record_info_filename [-t {0,1,2}] [-c codec.cfg] [-s {1,0}]", argv[0]); | 1216 | printf("\n %s record_info_filename [-t {0,1,2}] [-c codec.cfg] [-s {1,0}]", argv[0]); |
| 1217 | printf("\n\n"); | 1217 | printf("\n\n"); |
-
请 注册 或 登录 后发表评论