video playing with paperclip ffmpeg

Refresh

November 2018

Views

1.2k time

2

I've been having problems playing uploaded videos in my ruby on rails app.

So I am using the paperclip-ffmpeg gem to process my videos when uploaded, and I am able to create a thumbnail of the video but I am not able to play the video. When I right click on the video I am able to download and I can play it using the player on my computer but I am not able to play it in my view. Also when I right click on it the options for "play", "skip", etc. are all blocked. Here is my model:

class Video < ActiveRecord::Base
    has_attached_file :clip, :styles => {
            :medium => { :geometry => "640x480", :format => 'flv'},
            :thumb => {:geometry => "100x100#", :format => 'jpg', :time => 10}
        }, :processors => [:ffmpeg]
    do_not_validate_attachment_file_type(:clip)
end

And here is my view:

<table class="table">
                    <tr>
                        <th>Video</th>
                        <th>Title</th>
                        <th>Caption</th>
                    </tr>
                    <% @video.each do |video| %>
                        <tr>
                            <td>
                                <%= image_tag video.clip.url(:thumb) %>
                                <%= video_tag video.clip.url(:medium) %>
                            </td>
                            <td>
                                <%= label_tag video.title %>
                            </td>
                            <td>
                                <%= label_tag video.caption %>
                            </td>
                        </tr>
                    <% end %>
                </table>

I have also tried using the videojs_rails gem but I wasn't able to play the video using that either. I would greatly appreciate it if someone could help me out, I've been searching for an answer everywhere but haven't come across one that has worked for me.

Thanks in advance

1 answers

2

Привет , ребята , я , наконец , понял, что был неправ, я должен указать typeатрибут в видеотег, а также вместо того , чтобы использовать flvформат я превращал мое видео mp4с этими изменениями я был в состоянии играть видео я закачал.

Старый тег:

<%= video_tag video.clip.url(:medium) %>

Новый тег:

<%= video_tag video.clip.url(:medium), controls: true, type: "video/mp4", size: "400x400" %>

Надеюсь, что это поможет кому-то