문제 해결을 도와주세요.
비디오 파일로드를 구현했습니다. gem paperclip-av-transcoder를 사용했습니다.
모델:
class Video < ActiveRecord::Base
has_attached_file :video,
:url => ":localhost/system/:class/:attachment/:id/:style/:filename",
:path => ":rails_root/public/system/:class/:attachment/:id/:style/:filename",
:styles => {
:medium => { :geometry => "640x480", :format => 'flv' },
:thumb => { :geometry => "200x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]
validates_attachment_content_type :video, :content_type => ["video/mp4", "video.mov", "video/mpeg","video/mpeg4", "image/jpg", "image/jpeg"]
end
제어 장치:
def create
@video = Video.new(video_params)
if @video.save
flash[:success] = :video_created
redirect_to @video
else
flash.now[:error] = :video_not_created
redirect_to @video
end
end
show.html.erb :
<video width="320" height="240" controls>
<source src="<%= @video.video_file_name %>" type="<%= @video.video_content_type %>">
</video>
결과 비디오 파일이 시스템에로드되지만 표시되지는 않습니다.
방화범이 잘못된 방법을 보여줍니다.
<video width="320" height="240" controls="">
<source src="mmm.mp4" type="video/mp4">
</video>
실제 경로는 다음과 같습니다.
/home/kalinin/rails/vd/public/system/videos/videos/17/medium/mmm.flv
화면에 비디오를 표시하는 방법을 이해하지 못합니다.
아래 코드를 시도하십시오
<%= video_tag @video.video.path(:medium), type: @video.video_content_type %>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다