gpt4 book ai didi

ruby-on-rails - 使用 Ruby on Rails 4 应用程序在视频上出现错误

转载 作者:行者123 更新时间:2023-12-04 23:03:21 24 4
gpt4 key购买 nike

所以这是我尝试上传视频后立即遇到的错误

enter image description here

这是我的帖子展示

<%= 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 %>

这是我的帖子模型
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

我很好奇之前是否有人遇到过这个问题,我想知道我是否可以就如何解决这个问题获得任何帮助。我正在使用回形针 av-transcoder gem、ffmpeg 和回形针 gem。如果需要,我可以添加更多信息

如果这有帮助,这是我的后期 Controller
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

最佳答案

您的文件似乎没有正确转换。请在创建视频后观察日志以检查转换是否完成。

此外,将转换移至背景可能会更好,这可能需要很长时间:https://github.com/jrgifford/delayed_paperclip/

关于ruby-on-rails - 使用 Ruby on Rails 4 应用程序在视频上出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36946778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com