Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

courseware
杨树明 5 years ago
commit 821de63da6

@ -238,7 +238,9 @@ module CoursesHelper
# 获取课堂的资源数 # 获取课堂的资源数
def get_attachment_count(course, category_id) 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 end
# 获取课堂的视频数 # 获取课堂的视频数

@ -23,6 +23,7 @@ module AliyunVod::Service::Base
result result
rescue => ex rescue => ex
::Util.logger_error(ex) ::Util.logger_error(ex)
""
#raise AliyunVod::Error, ex.message #raise AliyunVod::Error, ex.message
end end

@ -26,7 +26,7 @@ module AliyunVod::Service::VideoManage
result result
end end
# 读取视频编码格式 # 读取视频编码格式与视频格式
def get_meta_code_info(video_id) def get_meta_code_info(video_id)
params = { params = {
Action: 'GetMezzanineInfo', Action: 'GetMezzanineInfo',
@ -36,11 +36,14 @@ module AliyunVod::Service::VideoManage
result = request(:post, params) result = request(:post, params)
Rails.logger.info("#######:#{result['Mezzanine']['VideoStreamList'][0]['CodecName']}") 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 rescue => e
Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}" Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}"
"" {codecnamne: "", format: ""}
end end
# 删除视频信息 # 删除视频信息

@ -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 :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 :search_by_container, -> (ids) {where(container_id: ids)}
scope :unified_setting, -> {where("unified_setting = ? ", 1)} scope :unified_setting, -> {where("unified_setting = ? ", 1)}
scope :published, -> {where(is_publish: 1)}
validates_length_of :description, maximum: 100, message: "不能超过100个字符" validates_length_of :description, maximum: 100, message: "不能超过100个字符"

@ -29,14 +29,14 @@ class Videos::BatchPublishService < ApplicationService
video.status = "published" video.status = "published"
end end
# 标清转码为h264 # 非MP4 H264编码的都转码
code_info = AliyunVod::Service.get_meta_code_info(video.uuid) 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: #{code_info[:format]}, #{code_info[:codecnamne]}")
if code_info[:format] == "mp4" && code_info[:codecnamne].present? && code_info[:codecnamne].start_with?('h264')
video.transcoded = true video.transcoded = true
#Rails.logger.info("####video.uuid:#{video.uuid}") result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
#result = AliyunVod::Service.get_play_info(video.uuid) play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present?
# Rails.logger.info("####video.result:#{result}") video.play_url = play_url
#video.play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL']
else else
AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID)
end end

@ -18,9 +18,7 @@ class Videos::DispatchCallbackService < ApplicationService
video.save! video.save!
when 'SnapshotComplete' then # 封面截图完成 when 'SnapshotComplete' then # 封面截图完成
return if video.cover_url.present? return if video.cover_url.present?
result = AliyunVod::Service.get_play_info(video.uuid) rescue nil video.update!(cover_url: params['CoverUrl'])
play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result
video.update!(cover_url: params['CoverUrl'], play_url: play_url)
when 'StreamTranscodeComplete' then # 转码完成 when 'StreamTranscodeComplete' then # 转码完成
#return if video.play_url.present? #return if video.play_url.present?
video.update!(play_url: params['FileUrl'], transcoded: true) video.update!(play_url: params['FileUrl'], transcoded: true)

@ -4,4 +4,4 @@ You are allowed to:
1. Remove rake task 1. Remove rake task
2. Add existing rake tasks 2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project. To add existing rake tasks automatically delete this file and reload the project.
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitlab-3.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install gitlab-3.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v3.2.0 and build and push gitlab-3.2.0.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings> --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitlab-3.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install gitlab-3.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install gitlab-3.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v3.2.0 and build and push gitlab-3.2.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>

@ -3,7 +3,7 @@ namespace :video_transcode do
desc "视频转码成h264" desc "视频转码成h264"
task :submit => :environment do task :submit => :environment do
Video.find_each do |v| 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}" p "--- Start submit video trans code #{v.uuid}"
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e')
else else

@ -706,7 +706,7 @@ class CoursesBanner extends Component {
{this.props.isStudent()?this.props.current_user&&this.props.current_user.course_is_end===true?"":<a className="fr user_default_btn user_blue_btn mr20 font-18" {this.props.isStudent()?this.props.current_user&&this.props.current_user.course_is_end===true?"":<a className="fr user_default_btn user_blue_btn mr20 font-18"
onClick={() => this.exitclass()} onClick={() => this.exitclass()}
> 退出课堂 </a>:""} > 永久退出课堂 </a>:""}
</div> </div>

@ -443,7 +443,7 @@ function VideoUploadList (props) {
<div class="description "> <div class="description ">
<div>上传说明目前不支持断点续传单个视频文件最大限制500M单次最多支持3个视频文件上传 </div> <div>上传说明目前不支持断点续传单个视频文件最大限制500M单次最多支持3个视频文件上传 </div>
<div>视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div> <div>视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div>
<div>温馨提示<span class="color-orange-tip">为了更好播放体验建议您优先上传MP4格式如果您是自己录制视频建议您保存的时候将视频编码设置为AVC(H264)</span></div></div> <div>温馨提示<span class="color-orange-tip">为了更好播放体验建议您优先上传MP4格式如果您是自己录制视频建议您保存的时候将视频编码设置为AVC(H264)</span></div></div>
</div> </div>
{!noUploads && <React.Fragment> {!noUploads && <React.Fragment>

Loading…
Cancel
Save