Ruby on rails 使用Ruby on Rails 4应用程序获取视频时出错
这就是我在上传视频后遇到的错误 这是我的邮展Ruby on rails 使用Ruby on Rails 4应用程序获取视频时出错,ruby-on-rails,ruby,video,ffmpeg,Ruby On Rails,Ruby,Video,Ffmpeg,这就是我在上传视频后遇到的错误 这是我的邮展 <%= video_tag @post.video.url(:medium), controls: true, style: "max-width: 100%;" %> <p> <strong>Description:</strong> <%= @post.description %> </p> <% if @post.user == current_user
<%= video_tag @post.video.url(:medium), controls: true, style: "max-width: 100%;" %>
<p>
<strong>Description:</strong>
<%= @post.description %>
</p>
<% if @post.user == current_user %>
<%= link_to 'Edit', edit_post_path(@post) %>
<% end %>|
<%= link_to 'Back', posts_path %>
您的文件似乎未正确转换。创建视频后,请观察日志,检查转换是否完成
另外,最好将转换移到后台,这样做可能需要很长时间:看起来您的文件未正确转换。创建视频后,请观察日志,检查转换是否完成
另外,最好将转换移到后台,这样做可能需要很长时间:你能打开控制台看看是否有错误吗?@Uzbekjon我打开了浏览器控制台,但没有显示任何内容。我不知道你指的是rails控制台还是浏览器控制台。您是否也可以看到添加该
视频标记的渲染HTML?让我们看看有没有什么问题…@Uzbekjon不知道你的意思。但这就是你要找的吗?你能从浏览器中访问你的视频文件吗?/system/posts/videos/000/000/007/medium/20140710_175743_001.mp4?1461961478
?你能打开你的控制台看看是否有任何错误吗?@Uzbekjon我打开了我的浏览器控制台,但没有显示任何内容。我不知道你指的是rails控制台还是浏览器控制台。您是否也可以看到添加该视频标记的渲染HTML?让我们看看有没有什么问题…@Uzbekjon不知道你的意思。但是这就是你要找的吗?你能从浏览器/system/posts/videos/000/000/007/medium/20140710_175743_001.mp4?1461961478
访问你的视频文件吗?
class Post < ActiveRecord::Base
belongs_to :user
has_attached_file :video, styles: {
:medium => {
:geometry => "640x480",
:format => 'mp4'
},
:thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
}, :processors => [:transcoder]
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
end
def index
@posts = Post.all
end
def show
end
def new
@post = current_user.posts.build
end
def edit
end
def create
@post = current_user.posts.build(post_params)
if @post.save
redirect_to @post, notice: 'Post was successfully created.'
else
render :new
end
end
def update
if @post.update(post_params)
redirect_to @post, notice: 'Post was successfully updated.'
else
render :edit
end
end
def destroy
@post.destroy
redirect_to posts_url
end
private
def set_post
@post = Post.find_by(id: params[:id])
end
def correct_user
@post = current_user.posts.find_by(id: params[:id])
redirect_to posts_path, notice: "Not authorized to edit this post" if @post.nil?
end
def post_params
params.require(:post).permit(:description, :video)
end
end