Recherche avancée

Médias (91)

Autres articles (100)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (8526)

  • Exit Status with ffmpeg Command in Rails

    25 novembre 2012, par DragonFire353

    I am trying to get uploaded videos to be converted in the background, running windows. I am using :

    gem 'paperclip'
    gem 'aasm'
    gem 'delayed_job_active_record'
    gem 'ffmpeg'

    I was using purely paperclip before and making the user wait and it worked great, now I am having problems with the return of the error status for the command, I have tried editing to possible fix the command wondering if it was failing in the first place but I keep getting :

    undefined method `exitstatus' for nil:NilClass

    no matter what. I've tried looking this up and it's supposedly valid syntax that should work... Also I've commented out the actual spawn do part because I get another error if I leave that in :

    wrong number of arguments

    Does anyone know how to properly get this working ? I've went through a few tutorials that have bits and pieces of what I need but I can't get them working together. Here's what I have so far, lemme know if you need more :

    Model :

       class Video < ActiveRecord::Base
     include AASM

     belongs_to :user
     has_many :comments, dependent: :destroy
     attr_accessible :video, :user_id, :video_file_name, :title, :public, :description, :views

     has_attached_file :video, url: "/users/:user_id/videos/:id/:basename_:style.:extension"
     #, :styles => {
        # :video => { geometry: "800x480>", format: 'webm' },
        # :thumb => { geometry: "200x200>", format: 'png', time: 3 },
      # }, processors: [:ffmpeg], url: "/users/:user_id/videos/:id/:basename_:style.:extension"

     #process_in_background :video #causes death

     validates :video, presence: true
     validates :description, presence: true, length: { minimum: 5, maximum: 100}
     validates :title, presence: true, length: { minimum: 1, maximum: 15 }

     validates_attachment_size :video, less_than: 1.gigabytes
     validates_attachment :video, presence: true

     default_scope order: 'created_at DESC'

     Paperclip.interpolates :user_id do |attachment, style|attachment.instance.user_id
     end

     #acts as state machine plugin
     aasm state: :pending do
      state :pending, initial: true
      state :converting
      state :converted
      #, enter: :set_new_filename
      state :error

       event :convert do
        transitions from: :pending, to: :converting
      end

       event :converted do
        transitions from: :converting, to: :converted
      end

       event :failure do
         transitions from: :converting, to: :error
       end
     end

      # This method is called from the controller and takes care of the converting
     def convert
       self.convert!

       #spawn a new thread to handle conversion
       #spawn do
         success = delay.system(convert_command)
         logger.debug 'Converting File: ' + success.to_s
         if success && $?.exitstatus.to_i == 0
           self.converted!
         else
           self.failure!
         end
       #end
     end

     def self.search(search)
       if search
         find(:all, conditions: ["public = 't' AND title LIKE ?", "%#{search}%"], order: "created_at DESC")
       else
         find(:all, conditions: ["public = 't'"], order: "created_at DESC")
       end
     end

     def self.admin_search(search)
       if search
         find(:all, conditions: ['title LIKE ?', "%#{search}%"], order: "created_at DESC")
       else
         find(:all, order: "created_at DESC")
       end
     end

     private
       def convert_command
         #construct new file extension
         webm =  "." + id.to_s + ".webm"

         #build the command to execute ffmpeg
         command = <<-end_command
           ffmpeg -i #{ RAILS_ROOT + '/public/users/:user_id/videos/:id/:basename_:style.:extension' }  -ar 22050 -ab 32 -s 1280x720 -vcodec webm -r 25 -qscale 8 -f webm -y #{ RAILS_ROOT + '/public/users/:user_id/videos/:id/:basename_.webm' }

         end_command

         logger.debug "Converting video...command: " + command
         command
       end

       handle_asynchronously :convert_command

       # This updates the stored filename with the new flash video file
       def set_new_filename
         #update_attribute(:filename, "#{filename}.#{id}.webm")
         update_attribute(:content_type, "video/x-webm")
       end

    end

    Controller :

    class VideosController < ApplicationController
    before_filter :signed_in_user, only: [:upload, :update, :destroy]
    before_filter :admin_user, only: :admin_index

    def upload
       @video = Video.new
       # generate a unique id for the upload
       @uuid = (0..29).to_a.map {|x| rand(10)}
    end

    def create
       @video = Video.new(params[:video])
       @video.user_id = current_user.id

       if @video.save
           @video.convert
           flash[:success] = "Uploaded Succefully!"
           redirect_to @video.user
       else
           render 'upload'
       end
    end

    def show
       @video = Video.find(params[:id])
       @comments = @video.comments.paginate(page: params[:page], per_page: 6)
       if !@video.public
           if !signed_in? || current_user.id != @video.user_id  && !current_user.admin && !current_user.approved?(@video.user)
           flash[:notice] = "Video is private"
           redirect_to root_path
       end
    end
    end

    def update
       @video = Video.find(params[:id])
       if @video.update_attributes(params[:video])
     flash[:success] = "Video preferences saved"
    else
       flash[:fail] = "Failed to update video preferences"
    end
    redirect_to :back
    end

    def destroy
       @video = Video.find(params[:id])
       @video.destroy
       flash[:deleted] = "Deleted Succefully!"
       redirect_to :back
    end

    def index
       @videos = Video.paginate(page: params[:page], per_page: 6).search(params[:search])
    end

    def admin_index
       @videos = Video.paginate(page: params[:page], per_page: 6).admin_search(params[:search])
    end

    def ajax_video_comments
       @video = Video.find(params[:id])
       @comments = @video.comments.paginate(page: params[:page], per_page: 6)

       respond_to do |format|
       format.js   { render partial: 'shared/comments', content_type: 'text/html' }
    end
    end

    def ajax_video_watched
       @video = Video.find(params[:id])
       @video.views += 1
       @video.save
    end

    private

    def signed_in_user
       redirect_to root_path, notice: "Please Login." unless signed_in?
    end

    def admin_user
       redirect_to(root_path) unless current_user.admin?
    end

    end
  • Trolls in trouble

    6 juin 2013, par Mans — Law and liberty

    Life as a patent troll is hopefully set to get more difficult. In a memo describing patent trolls as a “drain on the American economy,” the White House this week outlined a number of steps it is taking to stem this evil tide. Chiming in, the Chief Judge of the … Continue reading

  • Background Video Processing with Rails

    23 octobre 2013, par Matthew Snyder

    I am trying to get uploaded videos to be converted in the background, running windows. Some of what I am using :

    gem 'paperclip'
    gem 'delayed_job_active_record'
    gem 'ffmpeg'

    I have edited the registry to allow the ffmpeg command to be ran from anywhere, I get a popup that I assume is ffmpeg because it goes away too quickly, guess the command is wrong so if anyone knows what's wrong with it please let me know. But the real problem is that it just hangs there, it says :

    [2012-12-09 22:47:03] ERROR invalid body size.
    [2012-12-09 22:47:03] ERROR Errno::ECONNABORTED: An established connection was a
    borted by the software in your host machine.
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `write'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `<<'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `_write_data'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:368:i
    n `send_body_string'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:249:i
    n `send_body'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:152:i
    n `send_response'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:110:in
    `run'
           C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `blo
    ck in start_thread'

    Does anyone know how to properly get this working ? I've went through a few tutorials that have bits and pieces of what I need but I can't get them working together. Here's what I have so far, lemme know if you need more :

    Model :

    class Video < ActiveRecord::Base

     belongs_to :user
     has_many :comments, dependent: :destroy
     attr_accessible :video, :user_id, :video_file_name, :title, :public, :description, :views

     has_attached_file :video, url: "/users/:user_id/videos/:id/:basename_:style.:extension"

     #process_in_background :video #causes death

     validates :video, presence: true
     validates :description, presence: true, length: { minimum: 5, maximum: 100}
     validates :title, presence: true, length: { minimum: 1, maximum: 15 }

     validates_attachment_size :video, less_than: 1.gigabytes
     validates_attachment :video, presence: true

     default_scope order: 'created_at DESC'

     Paperclip.interpolates :user_id do |attachment, style|attachment.instance.user_id
     end

     #before_post_process do |video|
      # false if video.status == "converting"
     #end

     def perform
       command = <<-end_command
         start ffmpeg -i #{ '/public/users/:user_id/videos/:id/:basename_:style.:extension' }  -ar 22050 -ab 32 -s 1280x720 -vcodec webm -r 25 -qscale 8 -f webm -y #{ '/public/users/:user_id/videos/:id/:basename_.webm' }

       end_command
       success = system(command)
       logger.debug 'Converting File: ' + success.to_s
       if success && $?.exitstatus.to_i == 0
         #self.converted!
         self.status = "converted"
       else
         #self.failure!
         self.status = "failed"
       end
     end

     handle_asynchronously :perform

     def self.search(search)
       if search
         find(:all, conditions: ["public = 't' AND title LIKE ?", "%#{search}%"], order: "created_at DESC")
       else
         find(:all, conditions: ["public = 't'"], order: "created_at DESC")
       end
     end

     def self.admin_search(search)
       if search
         find(:all, conditions: ['title LIKE ?', "%#{search}%"], order: "created_at DESC")
       else
         find(:all, order: "created_at DESC")
       end
     end

     private

       # This updates the stored filename with the new flash video file
       def set_new_filename
         #update_attribute(:filename, "#{filename}.#{id}.webm")
         update_attribute(:content_type, "video/x-webm")
       end

    end

    Controller :

    class VideosController < ApplicationController
       before_filter :signed_in_user, only: [:upload, :update, :destroy]
       before_filter :admin_user, only: :admin_index

       def upload
           @video = Video.new
           # generate a unique id for the upload
           @uuid = (0..29).to_a.map {|x| rand(10)}
       end

       def create
           @video = Video.new(params[:video])
           @video.user_id = current_user.id

           if @video.save
               @video.delay.perform
               flash[:success] = "Uploaded Succefully!"
               redirect_to @video.user
               Delayed::Worker.new.start
           else
               render 'upload'
           end
       end

       def show
           @video = Video.find(params[:id])
           @comments = @video.comments.paginate(page: params[:page], per_page: 6)
           if !@video.public
               if !signed_in? || current_user.id != @video.user_id  && !current_user.admin && !current_user.approved?(@video.user)
               flash[:notice] = "Video is private"
               redirect_to root_path
           end
       end
       end

       def update
           @video = Video.find(params[:id])
           if @video.update_attributes(params[:video])
         flash[:success] = "Video preferences saved"
       else
           flash[:fail] = "Failed to update video preferences"
       end
       redirect_to :back
     end

       def destroy
           @video = Video.find(params[:id])
           @video.destroy
           flash[:deleted] = "Deleted Succefully!"
           redirect_to :back
       end

       def index
           @videos = Video.paginate(page: params[:page], per_page: 6).search(params[:search])
       end

       def admin_index
           @videos = Video.paginate(page: params[:page], per_page: 6).admin_search(params[:search])
       end

       def ajax_video_comments
           @video = Video.find(params[:id])
           @comments = @video.comments.paginate(page: params[:page], per_page: 6)

           respond_to do |format|
           format.js   { render partial: 'shared/comments', content_type: 'text/html' }
       end
       end

       def ajax_video_watched
           @video = Video.find(params[:id])
           @video.views += 1
           @video.save
       end

       private

       def signed_in_user
           redirect_to root_path, notice: "Please Login." unless signed_in?
       end

       def admin_user
           redirect_to(root_path) unless current_user.admin?
       end

    end