courseware
anke1460 5 years ago
parent 1e84cf48af
commit 81de792408

@ -31,7 +31,7 @@ class Videos::BatchPublishService < ApplicationService
# 非MP4 H264编码的都转码
code_info = AliyunVod::Service.get_meta_code_info(video.uuid)
result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
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')
@ -45,7 +45,7 @@ class Videos::BatchPublishService < ApplicationService
end
if result.present?
video.duration = result["VideoBase"]["Duration"] if result["VideoBase"]["Duration"]
video.duration = result['PlayInfoList']['PlayInfo'][0]['Duration'] if result['PlayInfoList']['PlayInfo'][0]['Duration'].present?
end
video.save!

@ -80,9 +80,9 @@ namespace :video do
videos = Video.published.where("duration = 0")
videos.find_each do |v|
result = AliyunVod::Service.get_play_info(v.uuid)
if result.present? && result["VideoBase"]["Duration"].present?
p '-----#{v.id} , #{result["VideoBase"]["Duration"]]}'
v.update(duration: result["VideoBase"]["Duration"])
if result.present? && result['PlayInfoList']['PlayInfo'][0]['Duration'].present?
p "-----#{v.id} , #{result['PlayInfoList']['PlayInfo'][0]['Duration']}"
v.update(duration: result['PlayInfoList']['PlayInfo'][0]['Duration'])
end
end

Loading…
Cancel
Save