感谢您的回复 :) 没有错误消息,我在 segment.rb 文件中有 ffmpeg 命令,我什至不确定那是否是正确的地方?在 segment.rb 我有
class Segment < ActiveRecord::Base
attr_accessible :name, :source_video, :the_other_video
has_attached_file :source_video
has_attached_file :the_other_video
end
def append_to_video(the_other_video, output_file)
system "ffmpeg -i concat: \"#{the_other_video.source_video.path} | #{self.source_video.path}\" -c copy #{output_file}"
end
对于 _form.html.erb
<%= form_for(@segment) do |f| %>
<% if @segment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@segment.errors.count, "error") %> prohibited this segment from being saved:</h2>
<ul>
<% @segment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :source_video %><br />
<%= f.file_field :source_video %>
</div>
<div class="field">
<%= f.label :the_other_video %><br />
<%= f.file_field :the_other_video %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
对于 show.html.erb
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @segment.name %>
</p>
<p>
<b>Source Video:</b>
<%= link_to 'Download Source Video', @segment.source_video.url %>
</p>
<p>
<b>Output:</b>
<%= link_to 'Download Output', @segment.the_other_video.url %>
</p>
<%= link_to 'Edit', edit_segment_path(@segment) %> |
<%= link_to 'Back', segments_path %>
这是我的 schema.rb
ActiveRecord::Schema.define(:version => 20130801040708) do
create_table "segments", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "source_video_file_name"
t.string "source_video_content_type"
t.integer "source_video_file_size"
t.datetime "source_video_updated_at"
t.string "the_other_video_file_name"
t.string "the_other_video_content_type"
t.integer "the_other_video_file_size"
t.datetime "the_other_video_updated_at"
end
end
所以我上传了视频,当我按下创建片段时,我希望它将两个剪辑组合在一起,我不确定我会在哪里运行 ffmpeg 命令?再次感谢!