video playing with paperclip ffmpeg


November 2018


1.2k time


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]

And here is my view:

<table class="table">
                    <% @video.each do |video| %>
                                <%= image_tag video.clip.url(:thumb) %>
                                <%= video_tag video.clip.url(:medium) %>
                                <%= label_tag video.title %>
                                <%= label_tag video.caption %>
                    <% end %>

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


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

Старый тег:

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

Новый тег:

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

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