0
Carrierswave를 사용하여 비디오 파일을 내 Rails 앱에 업로드하고 있습니다. 내 동영상 모델에는 동영상의 방향 (예 : 90, 180, 270 등)을 저장하는 데 사용하는 '회전'속성이 있습니다.carrierwave : 업 로더 내의 활성 레코드 열
은 내가 비디오가 회전 여부를 결정하고있어 내 업 로더에서 "회전"의 값을 설정하려면 : 나는 모델을 참조하려면 어떻게
require 'mini_exiftool'
class VideoPathUploader < CarrierWave::Uploader::Base
process :encode
def encode
video = MiniExiftool.new(@file.path)
orientation = video.rotation
# save the orientation of the video record here ??
if orientation == 90
# rotate video
Rails.logger.debug "portrait video"
aspect_ratio = video.imageheight.to_f/video.imagewidth.to_f
encode_video(:mp4, custom: "-vf transpose=1", aspect: aspect_ratio)
else
aspect_ratio = video.imagewidth.to_f/video.imageheight.to_f
encode_video(:mp4, resolution: :same, aspect: aspect_ratio)
end
instance_variable_set(:@content_type, "video/mp4")
:set_content_type_mp4
end
을 중 하나를 업데이트의 내 업 로더 내의 속성?
오리엔테이션 = video.rotation model.rotation = 오리엔테이션
: