From 2a258ac9fb293260993066880fdca8169a6bfa2c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 09:40:04 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/videos/batch_publish_service.rb | 7 +++---- app/services/videos/dispatch_callback_service.rb | 4 +--- lib/gitlab-cli/.rakeTasks | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index cad8cfbd9..c47906192 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -33,10 +33,9 @@ class Videos::BatchPublishService < ApplicationService code_info = AliyunVod::Service.get_meta_code_info(video.uuid) if code_info.present? && code_info.start_with?('h264', 'h265') video.transcoded = true - #Rails.logger.info("####video.uuid:#{video.uuid}") - #result = AliyunVod::Service.get_play_info(video.uuid) - # Rails.logger.info("####video.result:#{result}") - #video.play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] + result = AliyunVod::Service.get_play_info(video.uuid) rescue nil + play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result + video.play_url = play_url else AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) end diff --git a/app/services/videos/dispatch_callback_service.rb b/app/services/videos/dispatch_callback_service.rb index 2e3d85987..4ff94a1c4 100644 --- a/app/services/videos/dispatch_callback_service.rb +++ b/app/services/videos/dispatch_callback_service.rb @@ -18,9 +18,7 @@ class Videos::DispatchCallbackService < ApplicationService video.save! when 'SnapshotComplete' then # 封面截图完成 return if video.cover_url.present? - result = AliyunVod::Service.get_play_info(video.uuid) rescue nil - play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result - video.update!(cover_url: params['CoverUrl'], play_url: play_url) + video.update!(cover_url: params['CoverUrl']) when 'StreamTranscodeComplete' then # 转码完成 #return if video.play_url.present? video.update!(play_url: params['FileUrl'], transcoded: true) diff --git a/lib/gitlab-cli/.rakeTasks b/lib/gitlab-cli/.rakeTasks index ea716fd52..f349995e9 100644 --- a/lib/gitlab-cli/.rakeTasks +++ b/lib/gitlab-cli/.rakeTasks @@ -4,4 +4,4 @@ You are allowed to: 1. Remove rake task 2. Add existing rake tasks To add existing rake tasks automatically delete this file and reload the project. ---> +--> From a1521276ed166cc834e113372641e62b4e51f5c9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 09:45:07 +0800 Subject: [PATCH 02/12] 1 --- app/services/videos/batch_publish_service.rb | 3 --- app/services/videos/dispatch_callback_service.rb | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index c47906192..18fa442d8 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -33,9 +33,6 @@ class Videos::BatchPublishService < ApplicationService code_info = AliyunVod::Service.get_meta_code_info(video.uuid) if code_info.present? && code_info.start_with?('h264', 'h265') video.transcoded = true - result = AliyunVod::Service.get_play_info(video.uuid) rescue nil - play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result - video.play_url = play_url else AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) end diff --git a/app/services/videos/dispatch_callback_service.rb b/app/services/videos/dispatch_callback_service.rb index 4ff94a1c4..7d5f239c6 100644 --- a/app/services/videos/dispatch_callback_service.rb +++ b/app/services/videos/dispatch_callback_service.rb @@ -18,7 +18,9 @@ class Videos::DispatchCallbackService < ApplicationService video.save! when 'SnapshotComplete' then # 封面截图完成 return if video.cover_url.present? - video.update!(cover_url: params['CoverUrl']) + result = AliyunVod::Service.get_play_info(video.uuid) rescue nil + play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result + video.update!(cover_url: params['CoverUrl'],play_url: play_url) when 'StreamTranscodeComplete' then # 转码完成 #return if video.play_url.present? video.update!(play_url: params['FileUrl'], transcoded: true) From df6496556b495ea831830dedbec9cd3af100120d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 09:46:54 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/libs/aliyun_vod/service/base.rb | 1 + app/services/videos/batch_publish_service.rb | 3 +++ app/services/videos/dispatch_callback_service.rb | 4 +--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/libs/aliyun_vod/service/base.rb b/app/libs/aliyun_vod/service/base.rb index ebbcce694..f10f079b4 100644 --- a/app/libs/aliyun_vod/service/base.rb +++ b/app/libs/aliyun_vod/service/base.rb @@ -23,6 +23,7 @@ module AliyunVod::Service::Base result rescue => ex ::Util.logger_error(ex) + "" #raise AliyunVod::Error, ex.message end diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 18fa442d8..022098fd4 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -33,6 +33,9 @@ class Videos::BatchPublishService < ApplicationService code_info = AliyunVod::Service.get_meta_code_info(video.uuid) if code_info.present? && code_info.start_with?('h264', 'h265') video.transcoded = true + result = AliyunVod::Service.get_play_info(video.uuid) rescue nil + play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result.present? + video.play_url = play_url else AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) end diff --git a/app/services/videos/dispatch_callback_service.rb b/app/services/videos/dispatch_callback_service.rb index 7d5f239c6..4ff94a1c4 100644 --- a/app/services/videos/dispatch_callback_service.rb +++ b/app/services/videos/dispatch_callback_service.rb @@ -18,9 +18,7 @@ class Videos::DispatchCallbackService < ApplicationService video.save! when 'SnapshotComplete' then # 封面截图完成 return if video.cover_url.present? - result = AliyunVod::Service.get_play_info(video.uuid) rescue nil - play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result - video.update!(cover_url: params['CoverUrl'],play_url: play_url) + video.update!(cover_url: params['CoverUrl']) when 'StreamTranscodeComplete' then # 转码完成 #return if video.play_url.present? video.update!(play_url: params['FileUrl'], transcoded: true) From f340b54c614b3fbabeb8e8f7e5152a38900f5aa1 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Wed, 11 Mar 2020 10:45:15 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/user/usersInfo/video/VideoUploadList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js index 3c053166a..2558e75fe 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js @@ -443,7 +443,7 @@ function VideoUploadList (props) {
上传说明:目前不支持断点续传,单个视频文件最大限制500M,单次最多支持3个视频文件上传
视频规格:avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm
-
温馨提示:为了更好播放的体验,建议您优先上传MP4格式。如果您是自己录制视频,建议您保存的时候将视频编码设置为AVC(H264)
+
温馨提示:为了更好的播放体验,建议您优先上传MP4格式。如果您是自己录制视频,建议您保存的时候将视频编码设置为AVC(H264)
{!noUploads && From 2caaf8c3469a564e8dce6dabef3eb8c9bacc84b7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 11:51:37 +0800 Subject: [PATCH 05/12] 1 --- app/libs/aliyun_vod/service/video_manage.rb | 9 ++++++--- app/services/videos/batch_publish_service.rb | 7 ++++--- lib/tasks/video_transcode.rake | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/libs/aliyun_vod/service/video_manage.rb b/app/libs/aliyun_vod/service/video_manage.rb index ef8e707b3..d93a0f5ef 100644 --- a/app/libs/aliyun_vod/service/video_manage.rb +++ b/app/libs/aliyun_vod/service/video_manage.rb @@ -26,7 +26,7 @@ module AliyunVod::Service::VideoManage result end - # 读取视频编码格式 + # 读取视频编码格式与视频格式 def get_meta_code_info(video_id) params = { Action: 'GetMezzanineInfo', @@ -36,11 +36,14 @@ module AliyunVod::Service::VideoManage result = request(:post, params) Rails.logger.info("#######:#{result['Mezzanine']['VideoStreamList'][0]['CodecName']}") - result['Mezzanine']['VideoStreamList'][0]['CodecName'] + codecnamne = result['Mezzanine']['VideoStreamList'].first['CodecName'] + file_url = result['Mezzanine']['FileURL'] + format = file_url&.split(".")&.last + {codecnamne: codecnamne, format: format} rescue => e Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}" - "" + [codecnamne: "", format: ""] end # 删除视频信息 diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 022098fd4..20ce4ac32 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -29,12 +29,13 @@ class Videos::BatchPublishService < ApplicationService video.status = "published" end - # 标清转码为h264 + # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) - if code_info.present? && code_info.start_with?('h264', 'h265') + Rails.logger.info("code_info: #{ode_info['format']}, #{code_info['codecnamne']}") + if code_info['format'] == "mp4" && code_info['codecnamne'].present? && code_info['codecnamne'].start_with?('h264') video.transcoded = true result = AliyunVod::Service.get_play_info(video.uuid) rescue nil - play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result.present? + play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present? video.play_url = play_url else AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index 955905632..a14b5bf8b 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -3,7 +3,7 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do Video.find_each do |v| - if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid).start_with?("h264", "h265") + if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)['codecnamne'].start_with?("h264", "h265") p "--- Start submit video trans code #{v.uuid}" AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') else From a587961744d6a812c8975e7cb44403c5466a95e7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 11:54:19 +0800 Subject: [PATCH 06/12] 1 --- app/services/videos/batch_publish_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 20ce4ac32..d0b5e8cef 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -31,7 +31,7 @@ class Videos::BatchPublishService < ApplicationService # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) - Rails.logger.info("code_info: #{ode_info['format']}, #{code_info['codecnamne']}") + Rails.logger.info("code_info: #{code_info['format']}, #{code_info['codecnamne']}") if code_info['format'] == "mp4" && code_info['codecnamne'].present? && code_info['codecnamne'].start_with?('h264') video.transcoded = true result = AliyunVod::Service.get_play_info(video.uuid) rescue nil From 828dbae5d883a46c0a8b904df8f0c1573d58131a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 11:57:21 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/videos/batch_publish_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index d0b5e8cef..697d9df7e 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -31,7 +31,10 @@ class Videos::BatchPublishService < ApplicationService # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) + Rails.logger.info("code_info: #{code_info}") Rails.logger.info("code_info: #{code_info['format']}, #{code_info['codecnamne']}") + Rails.logger.info("code_info: #{code_info[:format]}, #{code_info[:codecnamne]}") + return if code_info['format'] == "mp4" && code_info['codecnamne'].present? && code_info['codecnamne'].start_with?('h264') video.transcoded = true result = AliyunVod::Service.get_play_info(video.uuid) rescue nil From ace5effc7832c77e3d48803cedd567a3f45f6ea7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 11:58:33 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/videos/batch_publish_service.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 697d9df7e..553ffe4f2 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -31,11 +31,8 @@ class Videos::BatchPublishService < ApplicationService # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) - Rails.logger.info("code_info: #{code_info}") - Rails.logger.info("code_info: #{code_info['format']}, #{code_info['codecnamne']}") Rails.logger.info("code_info: #{code_info[:format]}, #{code_info[:codecnamne]}") - return - if code_info['format'] == "mp4" && code_info['codecnamne'].present? && code_info['codecnamne'].start_with?('h264') + if code_info[:format] == "mp4" && code_info[:codecnamne].present? && code_info[:codecnamne].start_with?('h264') video.transcoded = true result = AliyunVod::Service.get_play_info(video.uuid) rescue nil play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present? From b751a79b06157a961535ea77994ef50905cbb645 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 11:58:58 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E6=94=B9=E5=8F=98=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/video_transcode.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index a14b5bf8b..995f9a82f 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -3,7 +3,7 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do Video.find_each do |v| - if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)['codecnamne'].start_with?("h264", "h265") + if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)[:codecnamne].start_with?("h264", "h265") p "--- Start submit video trans code #{v.uuid}" AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') else From e466aafa95939c2f726089bc7dfb0de975a658ce Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 12:12:08 +0800 Subject: [PATCH 10/12] 1 --- app/libs/aliyun_vod/service/video_manage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/libs/aliyun_vod/service/video_manage.rb b/app/libs/aliyun_vod/service/video_manage.rb index d93a0f5ef..f80f31788 100644 --- a/app/libs/aliyun_vod/service/video_manage.rb +++ b/app/libs/aliyun_vod/service/video_manage.rb @@ -43,7 +43,7 @@ module AliyunVod::Service::VideoManage {codecnamne: codecnamne, format: format} rescue => e Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}" - [codecnamne: "", format: ""] + {codecnamne: "", format: ""} end # 删除视频信息 From 89875130b48c6b885f8e8992da03806714e845b9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Mar 2020 12:26:53 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=A7=86=E8=A7=92?= =?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9C=AA?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 4 +++- app/models/attachment.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8f024c1c6..0ee83e839 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -238,7 +238,9 @@ module CoursesHelper # 获取课堂的资源数 def get_attachment_count(course, category_id) - category_id.to_i == 0 ? course.attachments.size : course.attachments.where(course_second_category_id: category_id).size + identity = current_user.course_identity(course) + attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id) + identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size end # 获取课堂的视频数 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3ff9a6a90..1a9b50c3b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ApplicationRecord scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} + scope :published, -> {where(is_publish: 1)} validates_length_of :description, maximum: 100, message: "不能超过100个字符" From 8fc0396af695bd06bc83ef9e192083c16c263744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 11 Mar 2020 13:28:01 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/coursesDetail/CoursesBanner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index 7d2791b15..98c56ff37 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -706,7 +706,7 @@ class CoursesBanner extends Component { {this.props.isStudent()?this.props.current_user&&this.props.current_user.course_is_end===true?"": this.exitclass()} - > 退出课堂 :""} + > 永久退出课堂 :""}