Coder Social home page Coder Social logo

paperclip-av-transcoder's Introduction

Paperclip Transcoder

Audio/Video Transcoder for Paperclip using FFMPEG/Avconv.

This is a replacement for ( https://github.com/owahab/paperclip-ffmpeg ).

Status

Build Status Coverage Status Code Climate Dependency Status Gem Version

Installation

Add this line to your application's Gemfile:

gem 'paperclip-av-transcoder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paperclip-av-transcoder

Usage

In your model:

# app/models/user.rb
class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => {
    :medium => { :geometry => "640x480", :format => 'flv' },
    :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
  }, :processors => [:transcoder]
end

This will produce:

  1. A transcoded :medium FLV file with the requested dimensions if they will match the aspect ratio of the original file, otherwise, width will be maintained and height will be recalculated to keep the original aspect ration.
  2. A screenshot :thumb with the requested dimensions regardless of the aspect ratio.

Meta Data

Then paperclip-av-transcoder can optionally add uploaded file meta data to a database column for <your_attachment>_meta.

Example: Given a model called User with an attachment field named :avatar, create a new migration to add an avatar_meta column to the users table.

def change
  add_column :users, :avatar_meta, :data_type
end

You can use a data type of :json, :jsonb, :hstore or even just :string. Check what data types your database supports.

geometry

The geometry option has the following available modifiers:

  1. '!' - Keep the same aspect of the image/video, but with the passed dimesion.
  2. '#' - Pad the image/video.
  3. '<' - Enlarge the image/video.
  4. '>' - Shrink the image/video.

convert_options

The convert_options option lets you specify custom command line options to be sent to the ffmpeg command. The options are split into output and input, which define where in the pipeline they will be applied. Read more about which flags go where on the official documentation.

For example, sending in the -an flag would look like this:

has_attached_file :video, styles: {
  mobile: {
    format: "mp4",
    convert_options: {
      output: {
        an: nil # Remove audio track resulting in a silent movie, passing in nil results in `-an`,
        name: "value" # Results in `-name value` in the command line
      }
    }
  },
}

Contributing

  1. Fork it ( https://github.com/ruby-av/paperclip-av-transcoder/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

paperclip-av-transcoder's People

Contributors

attenzione avatar biow0lf avatar cjeffries avatar erkie avatar joaoffcosta avatar owahab avatar paulodealmeida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

paperclip-av-transcoder's Issues

Convert video WEBM TO MP4 Error

Hello i have a process

has_attached_file :video_presentacion, :styles => {
:original => { :geometry => "1280x720", :format => 'mp4',:convert_options => { :output => { :vcodec => 'libx264'}} },
:thumb => { :geometry => "250x250#", :format => 'png', :time => 12}
}, :processors => [:transcoder]

But ONLY FILES WEBM have a error to convert mp4

App 7899 stderr: Conversion failed!

App 7925 stdout: Validation failed: Video presentacion error while processing video for 4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w8: Command 'PATH=/usr/local/bin/:$PATH; ffmpeg -i '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w8.webm' -vcodec libx264 -s 1280x720 -acodec aac -strict experimental -y '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w820150716-7925-1ipibkg.mp4''

here log:

App 7899 stderr: [libx264 @ 0x2534440] AVFrame.format is not set
App 7899 stderr: [libx264 @ 0x2534440] AVFrame.width or height is not set
App 7899 stderr: [libx264 @ 0x2534440] Input picture width (1280) is greater than stride (0)
App 7899 stderr: Video encoding failed
App 7899 stderr: [libx264 @ 0x2534440] frame I:125 Avg QP:16.63 size: 53542
App 7899 stderr: [libx264 @ 0x2534440] frame P:8143 Avg QP:18.97 size: 1151
App 7899 stderr: [libx264 @ 0x2534440] frame B:22849 Avg QP:27.42 size: 52
App 7899 stderr: [libx264 @ 0x2534440] consecutive B-frames: 2.0% 0.1% 0.2% 97.6%
App 7899 stderr: [libx264 @ 0x2534440] mb I I16..4: 19.2% 71.8% 9.1%
App 7899 stderr: [libx264 @ 0x2534440] mb P I16..4: 0.3% 0.4% 0.0% P16..4: 5.1% 0.8% 0.7% 0.0% 0.0% skip:92.7%
App 7899 stderr: [libx264 @ 0x2534440] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.6% 0.0% 0.0% direct: 0.0% skip:99.4% L0:17.2% L1:82.8% BI: 0.0%
App 7899 stderr: [libx264 @ 0x2534440] 8x8 transform intra:65.9% inter:70.7%
App 7899 stderr: [libx264 @ 0x2534440] coded y,uvDC,uvAC intra: 67.2% 90.7% 69.3% inter: 0.5% 1.2% 0.1%
App 7899 stderr: [libx264 @ 0x2534440] i16 v,h,dc,p: 18% 20% 27% 35%
App 7899 stderr: [libx264 @ 0x2534440] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 23% 31% 3% 4% 4% 6% 5% 6%
App 7899 stderr: [libx264 @ 0x2534440] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 17% 4% 7% 6% 7% 5% 4%
App 7899 stderr: [libx264 @ 0x2534440] i8c dc,h,v,p: 54% 22% 19% 5%
App 7899 stderr: [libx264 @ 0x2534440] Weighted P-Frames: Y:0.1% UV:0.0%
App 7899 stderr: [libx264 @ 0x2534440] ref P L0: 83.9% 8.3% 7.1% 0.7% 0.0%
App 7899 stderr: [libx264 @ 0x2534440] ref B L0: 75.6% 24.1% 0.3%
App 7899 stderr: [libx264 @ 0x2534440] ref B L1: 91.3% 8.7%
App 7899 stderr: [libx264 @ 0x2534440] kb/s:4438.32
App 7899 stderr: [aac @ 0x26249c0] 2 frames left in the queue on closing
App 7899 stderr: Conversion failed!
App 7899 stderr: ffmpeg version git-2015-04-15-c5d4f87 Copyright (c) 2000-2015 the FFmpeg developers
App 7899 stderr: built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
App 7899 stderr: configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3
App 7899 stderr: libavutil 54. 22.101 / 54. 22.101
App 7899 stderr: libavcodec 56. 34.100 / 56. 34.100
App 7899 stderr: libavformat 56. 30.100 / 56. 30.100
App 7899 stderr: libavdevice 56. 4.100 / 56. 4.100
App 7899 stderr: libavfilter 5. 14.100 / 5. 14.100
App 7899 stderr: libswscale 3. 1.101 / 3. 1.101
App 7899 stderr: libswresample 1. 1.100 / 1. 1.100
App 7899 stderr: libpostproc 53. 3.100 / 53. 3.100
App 7899 stderr: Input #0, matroska,webm, from '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w8.webm':
App 7899 stderr: Metadata:
App 7899 stderr: encoder : GStreamer plugin version 1.2.4
App 7899 stderr:
App 7899 stderr: creation_time : 2015-04-15 17:18:00
App 7899 stderr: Duration: 00:00:31.17, start: 0.000000, bitrate: 1553 kb/s
App 7899 stderr: Stream #0:0(eng): Video: vp8, yuv420p, 1280x720, SAR 1:1 DAR 16:9,
App 7899 stderr: 1k tbr, 1k tbn, 1k tbc
App 7899 stderr: (default)
App 7899 stderr: Metadata:
App 7899 stderr: title : Video
App 7899 stderr: Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
App 7899 stderr: Metadata:
App 7899 stderr: title : Audio
App 7899 stderr: Output #0, image2, to '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w820150716-7925-1hx3qv8.png':
App 7899 stderr: Metadata:
App 7899 stderr: encoder : Lavf56.30.100
App 7899 stderr: Stream #0:0(eng): Video: png, rgb24, 250x250 [SAR 376:375 DAR 376:375], q=2-31, 200 kb/s, 1k fps, 1k tbn, 1k tbc (default)
App 7899 stderr: Metadata:
App 7899 stderr: title : Video
App 7899 stderr: encoder : Lavc56.34.100 png
App 7899 stderr: Stream mapping:
App 7899 stderr: Stream #0:0 -> #0:0 (vp8 (native) -> png (native))
App 7899 stderr: Press [q] to stop, [?] for help
App 7899 stderr: frame= 1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A dup=1 drop=1
App 7899 stderr: video:59kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
App 7925 stdout: Validation failed: Video presentacion error while processing video for 4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w8: Command 'PATH=/usr/local/bin/:$PATH; ffmpeg -i '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w8.webm' -vcodec libx264 -s 1280x720 -acodec aac -strict experimental -y '/tmp/4158602f121d1e6f0dc8ba45a4c25fa620150716-7925-p6w4w820150716-7925-1ipibkg.mp4'' returned 1. Expected 0

How to mute ffmpeg message?

Hi,

Is it possible to disable output message to console from ffmpeg in test environment?
I hope it can work just like rails logger, write to log file only when running tests.

Thanks and best regards

Video not uploading

Hello, i'm following every step, my images upload correctly, but video is not even trying to upload, not even a public folder is generated. Am i doing something wrong? I have ffmpeg installed and paperclip alone is clearly working.

I'd love to know if someone is getting it to work as i can't find any tutorial or answered question on the internets. Thanks ๐Ÿ˜ƒ

uninitialized constant Paperclip::Processor

I am getting the following error after starting the server :

/home/sachin/.rvm/gems/ruby-1.9.3-p551/gems/paperclip-av-transcoder-0.6.4/lib/paperclip/paperclip_processors/transcoder.rb:2:in `module:Paperclip': uninitialized constant Paperclip::Processor (NameError)

What am i doing wrong?

AVI and MOV conversions never work

I love this plugin, but AVI/MOV conversions to mp4 always errors out. Anyone know why?

Here's an example of one log file:
[AV] Found ["avconv"], using: Avconv
[AV] Running command: avconv -i "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry7.AVI" 2>&1
[paperclip] [transcoder] Transocding supported file /tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry7.AVI
[AV] Adding output parameter ["acodec", "aac"]
[AV] Adding output parameter ["strict", "experimental"]
[AV] Running command: avconv -loglevel quiet -i "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry7.AVI" -acodec aac -strict experimental -y "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry720151022-3723-xxgxix.mp4"
Av::CommandError: error while running command avconv -loglevel quiet -i "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry7.AVI" -acodec aac -strict experimental -y "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry720151022-3723-xxgxix.mp4": Command 'PATH=/usr/bin:$PATH; avconv -loglevel quiet -i "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry7.AVI" -acodec aac -strict experimental -y "/tmp/0cfcdbeb8752f2f04bae352148788e0020151022-3723-1hezry720151022-3723-xxgxix.mp4"' returned 1. Expected 0
Here is the command output:

    from /var/lib/gems/1.9.1/gems/av-0.8.0/lib/av.rb:32:in `rescue in run'
    from /var/lib/gems/1.9.1/gems/av-0.8.0/lib/av.rb:29:in `run'
    from /var/lib/gems/1.9.1/gems/av-0.8.0/lib/av/commands/base.rb:91:in `run'
    from /var/lib/gems/1.9.1/gems/av-0.8.0/lib/av/cli.rb:19:in `method_missing'
    from /var/lib/gems/1.9.1/gems/paperclip-av-transcoder-0.6.2/lib/paperclip/paperclip_processors/transcoder.rb:66:in `make'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/processor.rb:33:in `make'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:522:in `block in post_process_style'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:521:in `each'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:521:in `inject'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:521:in `post_process_style'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:512:in `block in post_process_styles'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:511:in `each'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:511:in `post_process_styles'
    from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:503:in `block (2 levels) in post_process'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:113:in `call'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:113:in `call'

... 3 levels...
from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/callbacks.rb:36:in run_paperclip_callbacks' from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:501:inblock in post_process'
from /var/lib/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in run_callbacks' from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/callbacks.rb:36:inrun_paperclip_callbacks'
from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:500:in post_process' from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:456:inpost_process_file'
from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:108:in assign' from /var/lib/gems/1.9.1/gems/paperclip-4.2.1/lib/paperclip/has_attached_file.rb:66:inblock in define_setter'
from (irb):7
from /var/lib/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/console.rb:90:in start' from /var/lib/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/console.rb:9:instart'
from /var/lib/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:69:in console' from /var/lib/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:inrun_command!'
from /var/lib/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands.rb:17:in <top (required)>' from bin/rails:4:inrequire'
from bin/rails:4:in `

'irb(main):008:0>

Preserve aspect ratio generates an error with AV in 0.6.4, is OK in 0.6.2

This works well in 0.6.2, but in 0.6.4 it seems that for

      :image => { :geometry => "320x!", :format => 'jpg', :time => Video.screenshot_time(attachment.instance) }

the command generated by gem is

avconv -ss 12 -i "/tmp/421b47ffd946ca083b65cd668c6b17e6150903-15269-1806hcy-.mp4" -f image2 -vframes 1 -s 320x -y "/tmp/421b47ffd946ca083b65cd668c6b17e6150903-15269-1806hcy-150903-15269-1jh1vbd-.jpg"

which generates an empty file.

Getting error while saving the video

I am getting following error while saving the video
error while running command ffmpeg -i "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx.mp4" -s 640x480 -y "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx20150423-3314-1ok2yh8.flv": Command 'ffmpeg -i "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx.mp4" -s 640x480 -y "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx20150423-3314-1ok2yh8.flv"' returned 1. Expected 0

Error is in this line while updating: if @worker.update(worker_params)

Following is my code:

Gemfile
gem 'paperclip-av-transcoder'

worker.rb
has_attached_file :video, :styles => {:medium => { :geometry => "640x480", :format => 'flv' },:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]

workers_controller.rb
def update
respond_to do |format|
if @worker.update(worker_params)
format.html { redirect_to @worker, notice: 'Worker was successfully updated.' }
format.json { render :show, status: :ok, location: @worker }
else
format.html { render :edit }
format.json { render json: @worker.errors, status: :unprocessable_entity }
end
end
end
def worker_params
params.require(:worker).permit(:video, :user_id, :profile_photo, :worker_spoken_languages_attributes => [:id, :worker_id, :spoken_language, :_destroy])
end

show.haml
%p
%strong Video:
= video_tag @worker.video.url
%p

Please tell if I am missing anything

How to make it choose ffmpeg over avconv?

How to make paperclip-av-transcoder choose ffmpeg over avconv if both are found?

http://runnable.com/VR3jBtJKSwh21EKs/paperclip-av-transcoder

Started POST "/default/topics" for ::ffff at 2015-04-05 14:05:33 +0000                                                                      
Processing by Forem::TopicsController#create as HTML                                                                                                    
  Parameters: {"utf8"=>"๏ฟฝ~\~S", "authenticity_token"=>"+6Ma4fmBeexCEFsP9z8b5Af5vJQKarMssAxFdIHMHGEkRcP09T/zgmlVAM4Trb2iHWkHVFGFrHBqO3E8GGAzJw==", "topic
"=>{"subject"=>"sfgfgsfg", "posts_attributes"=>{"0"=>{"text"=>"sfhsg", "photos_attributes"=>{"0"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x
00000004502798 @tempfile=#<File:/tmp/RackMultipart20150405-50-183sbay.gif>, @original_filename="test.gif", @content_type="image/gif", @headers="Content-
Disposition: form-data; name=\"topic[posts_attributes][0][photos_attributes][0][attachment]\"; filename=\"test.gif\"\r\nContent-Type: image/gif\r\n">}}}
}}, "commit"=>"Create Topic", "forum_id"=>"default"}                                                                                                    
  ^[[1m^[[35mUser Load (0.3ms)^[[0m  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]              
  ^[[1m^[[36mForem::Forum Load (0.2ms)^[[0m  ^[[1mSELECT  "forem_forums".* FROM "forem_forums" WHERE "forem_forums"."slug" = ?  ORDER BY "forem_forums".
"position" ASC LIMIT 1^[[0m  [["slug", "default"]]                                                                                                      
  ^[[1m^[[35mForem::Category Load (0.1ms)^[[0m  SELECT  "forem_categories".* FROM "forem_categories" WHERE "forem_categories"."id" = ? LIMIT 1  [["id", 
1]]                                                                                                                                                     
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-oihgom.gif'                                                                 
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi                                                        
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi                                                         
[AV] Found ["avconv", "ffmpeg"], using: Avconv                                                                                                          
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi                                                        
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi                                                         
[AV] Found ["avconv", "ffmpeg"], using: Avconv                                                                                                          
[AV] Running command: avconv -i "/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif" 2>&1                                                     
[paperclip] [transcoder] Transocding supported file /tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif                                        
[AV] Adding output parameter ["acodec", "aac"]                                                                                                          
[AV] Adding output parameter ["strict", "experimental"]                                                                                                 
[AV] Running command: avconv -loglevel quiet -i "/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif" -acodec aac -strict experimental -y "/tmp
/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid20150405-50-nyp8zp.mp4"                                                                             
[paperclip] [transcoder] Successfully transcoded 098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid to #<File:0x000000046bf298>                        
[paperclip] [qtfaststart] :source :dest                                                                                                                 
Command :: qtfaststart '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid20150405-50-nyp8zp.mp4' '/tmp/098f6bcd4621d373cade4e832627b4f620150405-5
0-1lz9oid20150405-50-nyp8zp20150405-50-1cczssi.mp4' 
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid20150405-50-nyp8zp20150405-50-1cczssi.mp4'                           
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif[0]' 2>/dev/null                   
Command :: identify -format %m '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif[0]'                                                        
Command :: convert '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid.gif' -coalesce -auto-orient -resize "x70" -crop "70x70+27+0" +repage -layer
s "optimize" '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid20150405-50-19tfyp0'                                                              
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1lz9oid20150405-50-19tfyp0'                                                 
  ^[[1m^[[36m (0.2ms)^[[0m  ^[[1mbegin transaction^[[0m                                                                                                 
  ^[[1m^[[35mForem::Topic Exists (0.4ms)^[[0m  SELECT  1 AS one FROM "forem_topics" WHERE ("forem_topics"."id" IS NOT NULL) AND "forem_topics"."slug" = 
? LIMIT 1  [["slug", "sfgfgsfg"]]                                                                                                                       
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-50-1kui4uq.gif'                                                                
  ^[[1m^[[36mSQL (0.7ms)^[[0m  ^[[1mINSERT INTO "forem_topics" ("subject", "forum_id", "user_id", "slug", "created_at", "updated_at") VALUES (?, ?, ?, ?
, ?, ?)^[[0m  [["subject", "sfgfgsfg"], ["forum_id", 1], ["user_id", 1], ["slug", "sfgfgsfg"], ["created_at", "2015-04-05 14:05:38.824979"], ["updated_a
t", "2015-04-05 14:05:38.824979"]]                                                                                                                      
  ^[[1m^[[35mSQL (0.2ms)^[[0m  INSERT INTO "forem_posts" ("text", "user_id", "topic_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)  [["text", "
sfhsg"], ["user_id", 1], ["topic_id", 9], ["created_at", "2015-04-05 14:05:38.828987"], ["updated_at", "2015-04-05 14:05:38.828987"]]                   
  ^[[1m^[[36mForem::Topic Load (0.2ms)^[[0m  ^[[1mSELECT  "forem_topics".* FROM "forem_topics" WHERE "forem_topics"."id" = ? LIMIT 1^[[0m  [["id", 9]]  
  ^[[1m^[[35mSQL (281.1ms)^[[0m  UPDATE "forem_topics" SET "last_post_at" = '2015-04-05 14:05:38.828987' WHERE "forem_topics"."id" = ?  [["id", 9]]     
  ^[[1m^[[36mForem::Subscription Load (0.4ms)^[[0m  ^[[1mSELECT  "forem_subscriptions".* FROM "forem_subscriptions" WHERE "forem_subscriptions"."topic_i
d" = ?  ORDER BY "forem_subscriptions"."id" ASC LIMIT 1000^[[0m  [["topic_id", 9]]

As one would expect, this was never a problem with paperclip-ffmpeg:

http://runnable.com/VSFEpaY88OsqHGa0/paperclip-reverted-to-ffmpeg

Started POST "/default/topics" for ::ffff at 2015-04-05 14:16:37 +0000                                                                      
Processing by Forem::TopicsController#create as HTML                                                                                                    
  Parameters: {"utf8"=>"๏ฟฝ~\~S", "authenticity_token"=>"ZLQT2hWb+VtRpso+IWo/iAv2bf6x2Fcgp/bV9F8bwQdouiumXUXMNbtJrrdpkGkW1AMByf8R1bxiZVLA7BiUOQ==", "topic
"=>{"subject"=>"shfhfhf", "posts_attributes"=>{"0"=>{"text"=>"asdasdasd", "photos_attributes"=>{"0"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile
:0x00000005ba0a40 @tempfile=#<File:/tmp/RackMultipart20150405-60-1au05n3.gif>, @original_filename="test.gif", @content_type="image/gif", @headers="Conte
nt-Disposition: form-data; name=\"topic[posts_attributes][0][photos_attributes][0][attachment]\"; filename=\"test.gif\"\r\nContent-Type: image/gif\r\n">
}}}}}, "commit"=>"Create Topic", "forum_id"=>"default"}                                                                                                 
  ^[[1m^[[35mUser Load (0.3ms)^[[0m  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]              
  ^[[1m^[[36mForem::Forum Load (0.2ms)^[[0m  ^[[1mSELECT  "forem_forums".* FROM "forem_forums" WHERE "forem_forums"."slug" = ?  ORDER BY "forem_forums".
"position" ASC LIMIT 1^[[0m  [["slug", "default"]]                                                                                                      
  ^[[1m^[[35mForem::Category Load (0.2ms)^[[0m  SELECT  "forem_categories".* FROM "forem_categories" WHERE "forem_categories"."id" = ? LIMIT 1  [["id", 
1]]                                                                                                                                                     
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-1d84keo.gif'                                                                
[paperclip] [ffmpeg] ffprobe "/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw04.gif" 2>&1                                                         
[paperclip] [ffmpeg] Command Success                                                                                                                    
[paperclip] [ffmpeg] Making...                                                                                                                          
[paperclip] [ffmpeg] Building Destination File: '098f6bcd4621d373cade4e832627b4f620150405-60-akyw04' + 'mp4'                                            
[paperclip] [ffmpeg] Destination File Built                                                                                                             
[paperclip] [ffmpeg] Adding Geometry                                                                                                                    
[paperclip] [ffmpeg] Adding Format                                                                                                                      
[paperclip] [ffmpeg] Adding Source                                                                                                                      
[paperclip] [ffmpeg] Building Parameters                                                                                                                
[paperclip] [ffmpeg] -i :source -acodec aac -strict experimental -y :dest                                                                               
Command :: ffmpeg -i '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw04.gif' -acodec aac -strict experimental -y '/tmp/098f6bcd4621d373cade4e83262
7b4f620150405-60-akyw0420150405-60-nx0j61.mp4'                                                                                                          
[paperclip] [qtfaststart] :source :dest                                                                                                                 
Command :: qt-faststart '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw0420150405-60-nx0j61.mp4' '/tmp/098f6bcd4621d373cade4e832627b4f620150405-6
0-akyw0420150405-60-nx0j6120150405-60-jbc80d.mp4'                                                                                                       
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw0420150405-60-nx0j6120150405-60-jbc80d.mp4'                             
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw04.gif[0]' 2>/dev/null                    
Command :: identify -format %m '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw04.gif[0]'                                                         
Command :: convert '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw04.gif' -coalesce -auto-orient -resize "x70" -crop "70x70+27+0" +repage -layers
 "optimize" '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw0420150405-60-1benqrt'                                                                
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-akyw0420150405-60-1benqrt'                                                  
  ^[[1m^[[36m (0.2ms)^[[0m  ^[[1mbegin transaction^[[0m                                                                                                 
  ^[[1m^[[35mForem::Topic Exists (0.5ms)^[[0m  SELECT  1 AS one FROM "forem_topics" WHERE ("forem_topics"."id" IS NOT NULL) AND "forem_topics"."slug" = 
? LIMIT 1  [["slug", "shfhfhf"]]                                                                                                                        
Command :: file -b --mime '/tmp/098f6bcd4621d373cade4e832627b4f620150405-60-kdq57l.gif'                                                                 
  ^[[1m^[[36mSQL (1.0ms)^[[0m  ^[[1mINSERT INTO "forem_topics" ("subject", "forum_id", "user_id", "slug", "created_at", "updated_at") VALUES (?, ?, ?, ?
, ?, ?)^[[0m  [["subject", "shfhfhf"], ["forum_id", 1], ["user_id", 1], ["slug", "shfhfhf"], ["created_at", "2015-04-05 14:16:42.081114"], ["updated_at"
, "2015-04-05 14:16:42.081114"]]                                                                                                                        
  ^[[1m^[[35mSQL (0.4ms)^[[0m  INSERT INTO "forem_posts" ("text", "user_id", "topic_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)  [["text", "
asdasdasd"], ["user_id", 1], ["topic_id", 9], ["created_at", "2015-04-05 14:16:42.085832"], ["updated_at", "2015-04-05 14:16:42.085832"]]               
  ^[[1m^[[36mForem::Topic Load (0.1ms)^[[0m  ^[[1mSELECT  "forem_topics".* FROM "forem_topics" WHERE "forem_topics"."id" = ? LIMIT 1^[[0m  [["id", 9]]  
  ^[[1m^[[35mSQL (49.7ms)^[[0m  UPDATE "forem_topics" SET "last_post_at" = '2015-04-05 14:16:42.085832' WHERE "forem_topics"."id" = ?  [["id", 9]]      
  ^[[1m^[[36mForem::Subscription Load (0.2ms)^[[0m  ^[[1mSELECT  "forem_subscriptions".* FROM "forem_subscriptions" WHERE "forem_subscriptions"."topic_i
d" = ?  ORDER BY "forem_subscriptions"."id" ASC LIMIT 1000^[[0m  [["topic_id", 9]]

FFMPEG hangs/stalls when converting large files

So in conjunction I am running Delayed Paperclip to process large files in the background (Not sure if that plays a big role). Couple things:



1) I cannot find anywhere in the source where the command ffmpeg is called. All I really want to do is save the output of ffmpeg to see if there any errors that I do not know about.



2) Large videos always seem to get hung up at a certain point: (the first file is being converted from the second file, and the third file is being converted from the fourth file)

<br />v2@web1 ~/divshare-v2 $ ls -alh /tmp <br />-rw------- 1 v2 v2 70M Sep 10 00:01 2158940a8739e7219125179e0d1528c120160909-14061-8dqfx020160909-14061-egeyeq.mp4 <br />-rw------- 1 v2 v2 515M Sep 9 23:57 2158940a8739e7219125179e0d1528c120160909-14061-8dqfx0.mp4 <br />-rw------- 1 v2 v2 145M Sep 9 23:33 76ba144beb8a14b6cf542225ef885a7c20160909-12733-1ui03vo20160909-12733-y7ywn.mp4 <br />-rw------- 1 v2 v2 604M Sep 9 23:27 76ba144beb8a14b6cf542225ef885a7c20160909-12733-1ui03vo.mp4 <br />

I have tried uploading a couple times and with different files. Always gets caught around the same point. However everything works perfectly when smaller videos (~100-200M).



This is the command being ran:

<br />v2@web1 ~/divshare-v2 $ ps ux | grep ffmpeg <br />USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND <br />v2 14588 26.4 2.9 849840 240524 ? Sl Sep09 12:00 ffmpeg -i /tmp/2158940a8739e7219125179e0d1528c120160909-14061-8dqfx0.mp4 -acodec aac -strict experimental -vcodec libx264 -vb 1000k -profile:v baseline -vf scale=-2:480 -acodec aac -ab 128k -preset slow -threads 0 -movflags faststart -y /tmp/2158940a8739e7219125179e0d1528c120160909-14061-8dqfx020160909-14061-egeyeq.mp4 <br />



Any sort of help debugging this would be awesome.



NOTE: I copied the above command and manually ran the command so that I could see some logs from ffmpeg, and worked seamlessly.

MPEG-4 containers, the moov atom must precede...

I am converting videos to the MP4 format but struck an issue today when attempting to play those converted videos on Android.

The documentation says that "MPEG-4 containers, the moov atom must precede any mdat atoms, but must succeed the ftyp atom."

Is there a setting or the like I should be passing to the transcoder that will achieve the above?

Getting just a black image

So when I upload my video, it shows just a black image. No play button or anything. I am very new to this and trying my best. Any help would be very helpful

mp4 files do not stream

Is qtfaststart or something equivalent being run on mp4 files because they don't play until completely downloaded. webm files don't have this issue.

Error on player when I upload

Im having an issue whenever I try to upload a video I get the video player to popup but the video player says error. No clue what is going on.

screen shot 2016-04-15 at 5 52 52 pm

Can't transcode flv-x files

content type discovered from file command: video/x-flv. See documentation to allow this combination.

There seems to be no docs that I can find.

has_attached_file :video, path: ":rails_root/private/videos/:video_user_name/:video_library_name/:filename", url: "private/videos/:video_user_name/:video_library_name/:filename", styles: {jv_mp4: {format: 'mp4', streaming: true}, jv_webm: {format: 'webm'}, thumb: {geometry: '640x360#', format: 'png', time: 5}}, processors: [:transcoder, :qtfaststart]

validates_attachment :video, presence: true, content_type: {content_type: %w(video/mpeg video/mp4 video/3gpp video/flv video/x-flv video/webm)}, size: {in: 0..90.megabytes}

It has no issues with mp4, webm, and 3gpp, other than this gem is not smart enough to know if the uploaded file is either mp4 or webm and will transcode a mp4 to a mp4 for example. But it chokes on flv.

Command error

Everything was working fine with the paperclip-ffmpeg version 1.0.1 but when I switch to version paperclip-ffmpeg 1.2.0 OR 'paperclip-av-transcoder', "0.6.2" I get this stack:

Command :: PATH=/usr/local/bin/ffmpeg:$PATH file -b --mime '/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150205-9953-enmm0q.MOV'
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
sh: -c: line 0: syntax error near unexpected token `then'
sh: -c: line 0: `PATH=/usr/local/bin/ffmpeg:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi'
Could not log "process_action.action_controller" event. Encoding::UndefinedConversionError: "\xEA" from ASCII-8BIT to UTF-8 ["...'"]

Av::CommandError - error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'PATH=/usr/local/bin/ffmpeg:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 2. Expected 0
Here is the command output:

:
  av (0.8.0) lib/av.rb:32:in `rescue in run'
  av (0.8.0) lib/av.rb:29:in `run'
  av (0.8.0) lib/av/cli.rb:24:in `detect_command'
  av (0.8.0) lib/av/cli.rb:7:in `initialize'
  av (0.8.0) lib/av.rb:24:in `cli'
  paperclip-av-transcoder (0.6.2) lib/paperclip/paperclip_processors/transcoder.rb:14:in `initialize'
  paperclip (4.2.1) lib/paperclip/processor.rb:33:in `make'

If i try to execute the command in my terminal:

$ PATH=/usr/local/bin/ffmpeg:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
-bash: syntax error near unexpected token `then'

Accessing file metadata using '<attachment>_meta'

You may optionally add `<attachment>_meta` to your model and it will get populated with information about the processed video.

What does this mean? Where and how does this need to be added to the model in order to work? There is a lack of context in the documentation on this subject. The way this is written looks like it has something to do with view markup, which seems contradictory to the instructions. I've looked at the source code and searched for any examples utilizing this feature, but can't make heads or tails of it. Can anyone provide additional detail on how to access file metadata using this gem? I really would like to be able to access an mp4 file's duration metadata.

If anyone can answer this question I would be more than happy to update the README to help others using this gem.

Edit: As a workaround I found an ffmpeg command that will grab the video duration from the metadata after it has been uploaded and saved. I set up an after_save callback on my video model that uses this to save the duration to the db.
duration = ffprobe -i #{file_path} -show_entries format=duration -v quiet -of csv="p=0"

Generated thumbnail files empty when using the "#" padding option

Firstly, thanks for creating this gem!
I just wanted to record an issue I ran into, and based on searches, a few others may have encountered. If I can find the time I will take a stab at finding a fix other than the workaround mentioned below.

The documentation examples I saw show:
thumb: { geometry: "100x100#", :format => 'jpg' }
Which should create a 100 by 100 thumbnail with padding. However, I found that a thumbnail would only be successfully created by removing the #. I hope this helps someone else!

thumbnail geometry ignores "!#<>"

I need to be able to upload videos of any size up to a maximum of 1080 pixels in either direction and create an equivalent thumbnail image.

However the options !, #, >, and < are ignored

full_thumb: { geometry: '1080x1080>', format: 'jpg', time: 1 }

produces the following log

[AV] Adding output parameter ["f", "image2"]
[AV] Adding output parameter ["vframes", "1"]
[AV] Adding input parameter [:ss, 1]
[AV] Adding output parameter [:s, "1080x1080"]

and the output image is always 1080x1080 regardless of input dimensions (in test case 640x360)

Thumbs depending on the video duration

Hi, as said in the title, i would like to add thumbs, depending on the video duration.

It it possible to define time using percentage? Or to use a variable duration? I know that the duration can be found in the _meta, but is it possible to retrieve it before the saving ?

Here is my code :

validates :title,
            length: { in: 2..60 }
  validates :description,
            length: { minimum: 2 }
  

  has_attached_file :content, styles: {
      :medium => {
          :format => 'mp4',
          #convert_options: {
              #output: {
                #name: 'value' # Results in `-name value` in the command line
              #}
          #}
      },
      :thumb0 => { :geometry => '320x180#', :format => 'jpeg', :time => 1.0 * duration / 6.0 },
      :thumb1 => { :geometry => '320x180#', :format => 'jpeg', :time => 2.0 * duration / 6.0},
      :thumb2 => { :geometry => '320x180#', :format => 'jpeg', :time => 3.0 * duration / 6.0},
      :thumb3 => { :geometry => '320x180#', :format => 'jpeg', :time => 4.0 * duration / 6.0},
      :thumb4 => { :geometry => '320x180#', :format => 'jpeg', :time => 5.0 * duration / 6.0},
      }, :processors => [:transcoder]


  validates_attachment :content, presence: true,
                       content_type: { content_type: /\Avideo\/.*\Z/ },
                       size: { :less_than => 2.gigabytes }

Thx in advance for your reply !
(After thinking about it i should have posted on StackOverflow instead... sorry about that)

qtfaststart

Is there a way to use qtfaststart with this library like paperclip-ffmpeg allowed?

Unable to upload MP4

I'm trying to upload an MP4 (see file below) but get the log error "Audio codec mp3 not compatible with flv".

http://techslides.com/demos/sample-videos/small.mp4

Generate multiple thumbnails from video

Greetings,
I'm trying to find a way to generate multiple thumbnails from uploaded video. After lot of searching i've found a way but it's pure ffmpeg command.

ffmpeg -ss number_of_thumb * (total_video/number_of_thumb)  -i video_file  -vframes 1 -s 320x240 thumb_%03d.jpg 

This is the url where i find this code: Debuggable
please somebody help me to generate this command to paperclip way or tell me how can i generate multiple thumbnails using paperclip-av-transcoder!

Thank you in advance.

Regards,
Arif

-ss and 'Unable to find a suitable output format for '00:00:00'

It seems that the -ss position for input defaults to 3 seconds. I would like to set it to 0, but when I set it to 0 I receive the following error: Unable to find a suitable output format for '00:00:00'.

class CustomGif < ActiveRecord::Base

  has_attached_file :gif, styles: {
    original: {
      format: "gif",
      convert_options: {
        input: {
          ss: '00:00:00' #I also tried just '0'
        },
        output: {
          t: "00:00:6.000"
        }
      }
    }
  }, :processors => [:transcoder]
  validates_attachment_content_type :gif, content_type: /\Avideo\/.*\Z/
end

When I enter 'custom_gif = CustomGif.new(gif: params['video'])' I receive the following output:

Command :: file -b --mime '/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-7r8ssc.MOV'
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["ffmpeg"], using: Ffmpeg
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["ffmpeg"], using: Ffmpeg
[AV] Running command: ffmpeg -i "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV" 2>&1
[paperclip] [transcoder] Transocding supported file /var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV
[AV] Adding output parameter ["f", "image2"]
[AV] Adding output parameter ["vframes", "1"]
[AV] Adding input parameter [:ss, 3]
[AV] Adding input parameter [:ss, 0]
[AV] Adding output parameter [:t, "00:00:6.000"]
[AV] Running command: ffmpeg -ss 3 0 -i "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV" -f image2 -vframes 1 -t 00:00:6.000 -y "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji20160821-33753-n7xnk3.gif"
Av::CommandError: error while running command ffmpeg -ss 3 0 -i "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV" -f image2 -vframes 1 -t 00:00:6.000 -y "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji20160821-33753-n7xnk3.gif": Command 'ffmpeg -ss 3 0 -i "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV" -f image2 -vframes 1 -t 00:00:6.000 -y "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji20160821-33753-n7xnk3.gif"' returned 1. Expected 0
Here is the command output: STDOUT:



STDERR:

ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --disable-lzma --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-33753-o48pji.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2016-08-22 02:11:36
    com.apple.quicktime.make: Apple
    com.apple.quicktime.software: 9.3.3
    com.apple.quicktime.model: iPhone 6s
    com.apple.quicktime.creationdate: 2016-08-21T22:11:36-0400
  Duration: 00:00:02.42, start: 0.000000, bitrate: 866 kb/s
    Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 480x360, 763 kb/s, 24 fps, 24 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2016-08-22 02:11:36
      handler_name    : Core Media Data Handler
      encoder         : H.264
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 84 kb/s (default)
    Metadata:
      creation_time   : 2016-08-22 02:11:36
      handler_name    : Core Media Data Handler
[NULL @ 0x7fcaf280c800] Unable to find a suitable output format for '0'
0: Invalid argument

Video Skewed (does not maintain aspect ratio)

The video uploaded does not maintain aspect ratio. In the readme it says, " '!' - Keep the same aspect of the image/video, but with the passed dimesion."

My goal is to be able to be able to have the video returned in a square (while maintaining the aspect ratio). Cropping from the center would be ideal, as well.

Any help would be greatly appreciated. I included my code below.

Here is a link to a skewed 500x500! video of my puppy:
http://s3.amazonaws.com/pivotdevelopment/posts/videos/102/square.mp4?1440617576

Here is the non-skewed version for comparison:
http://s3.amazonaws.com/pivotdevelopment/posts/videos/103/square.mp4?1440617933

class Video < Post

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

  #basename/extension is paperclip interpolation from attachment, can write own interpolations as needed

  # have to link /usr/local/bin to the linuxbrew version of ffmpeg
  has_attached_file :video,  path: "/posts/videos/:id/:style.:extension",
  :styles => {
    :square => {:geometry => "500x500!", :format => 'mp4', :streaming => true }
  },
  :processors => [:transcoder]

  validates_attachment :video, :presence => true,
                               :content_type => { content_type: ["video/mp4", "video/mov", "video/mpeg","video/mpeg4", "video/quicktime"] }

  def video_url
    video = self.video
    if video.present?
      return video.url(:square)
    end
  end

end

Av::CommandError for 0.6.4

Im still having this issue although it was fixed with this release.

Av::CommandError (error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'PATH=/usr/bin/:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 1. Expected 0
DEBUG [6a1eae9e]    Here is the command output:
DEBUG [6a1eae9e]    
DEBUG [6a1eae9e]    ):
DEBUG [6a1eae9e]      app/controllers/blog_posts_controller.rb:37:in `create'

Riails 6 and https://github.com/kreeti/kt-paperclip

Due to paperclip depreciation, I am suing kt-paperclip now, I am also using [paperclip-av-transcoder] for video processing, Due to this I am not able to fully migrate to kt-paperclip as a dependency paperclip installed, my code is using old paperclip gem. Do you have any plane to support kt-paperclip

Please suggest to me the solution for video processing.

convert_options causes NoMethodError when only :input is defined

In: lib/paperclip/paperclip_processors/transcoder.rb

Around line 117:

def set_convert_options options
  return options[:convert_options] if options[:convert_options].present?
  options[:convert_options] = {output: {}}
  return options[:convert_options]
end

This fails to add :output to the convert_options when I only have :input defined, so I get this error:

NoMethodError (undefined method `[]=' for nil:NilClass):

paperclip-av-transcoder (0.6.4) lib/paperclip/paperclip_processors/transcoder.rb:37:in `initialize'

referencing:

 @convert_options[:output][:s] = format_geometry(@geometry) if @geometry.present?

A workaround for now is to just have a blank :output=>{} in my paperclip attachment definition, but the logic of assinging a default to the convert_options is erroneous.

Thumbnail Generation Issue

Hey @owahab thanks for creating this gem.

I'm running into issues generating the thumbnail according to your example. I was wondering if you could give a little bit more details in the README on how to get it to work properly, including setups and such?

I thought I had to make sure my ffmpeg install had --with-openjpeg flagged, so I reinstalled it with that.

I also debugged through the commands and ffmpeg asked for me to add %03d to the jpg name. So my code is now

has_attached_file :video_content, :styles => {
        :medium => { :geometry => "640x480", :format => 'mp4' },
        :thumb => { :geometry => "320x240", :format => '%03d.jpg', :time => 10 }
    },
    :processors => [:transcoder],
    :s3_protocol => :https

Which now it it generates an empty jpg.

Any thoughts on how I'm supposed to be installing, setting up the configs, etc to make it generate a thumbnail correctly?

Thumbnail bad quality

Hi! I use your gem with the following settings:

  has_attached_file :video, styles:  {
    medium: { geometry: "640x480",  format: 'mp4' },
    thumbnail:  {  geometry: "220x130#",  format: 'jpg',  time: 3 }
  },
  processors: [:transcoder]

Somehow video without any defects looks a bit stretched horizontally on a thumbnail.

Do you have any ideas what could it be?

From Gemfile.lock:

    paperclip-av-transcoder (0.6.4)
      av (~> 0.9.0)
      paperclip (>= 2.5.2)

Av::CommandError - error while running command

I wasn't really sure where else to try and get help with my issues so I ended up posting here. Whenever I add styles to the file upload I get this error:

Command :: PATH=/usr/local/bin/:$PATH file -b --mime '/var/folders/9y/6w60_d8n3p5084sxpnl6kj900000gn/T/fe208ed3e8facea9700ed13929aef73720150121-32345-8vcuoz.mov'
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
sh: -c: line 0: syntax error near unexpected token `then'
sh: -c: line 0: `PATH=/usr/local/bin/:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi'
Completed 500 Internal Server Error in 861ms

Av::CommandError (error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'PATH=/usr/local/bin/:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 2. Expected 0
Here is the command output:

):

I don't really have any experience when interacting with gems and I haven't been able to find anything on this issue. Any help is greatly appreciated.

Thanks

Thumb not resizing to requested geometry

Hi there,

I have the following in my paperclip definition:
has_attached_file :video,
:default_url => '/filetype-icons/filetype-unknown.png',
:styles => {
:thumb => { :geometry => "32x32>", :format => 'png', :time => 10 }
},
:path => ":rails_root/public/apartment_files/:attachment/:id_partition/:style/:filename",
:url => "/apartment_files/:attachment/:id_partition/:style/:filename",
:processors => [:transcoder]

However, when transocding, the thumb does not transcode to 32x32. Instead it goes to 1920x1080. What could I be doing wrong?

Delayed job or job queue

Hi, this is exactly what I'm looking for, convert huge video files to smaller ones.

But I found it transcode files on form submit, it's there any delayed job or job queue to do this? that will make the web page more quickly, thanks.

Watching video

Could you add the code for adding the video to a view in the README?

ffmpeg failure: Could not get frame filename number 2 from pattern

I'm receiving this error when attempting to process a video. It appears that the command is missing the "vframes 1" option? When I run the ffmpeg command manually, it does work fine when I add "vframes 1". I'm using the master branch straight from github.

[image2 @ 0x7feda1824a00] Could not get frame filename number 2 from pattern '/var/folders/ys/wn_46zvs6jbgjvgnn45snf9m0000gn/T/dc5c7986daef50c1e02ab09b442ee34f20141018-34360-1kbemf620141018-34360-1615t53.jpg' (either set updatefirst or use a pattern like %03d within the filename pattern)
av_interleaved_write_frame(): Invalid argument
frame=    2 fps=0.0 q=3.6 Lsize=N/A time=00:00:00.06 bitrate=N/A
video:204kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
Av::CommandError: error while running command ffmpeg -i "/var/folders/ys/wn_46zvs6jbgjvgnn45snf9m0000gn/T/dc5c7986daef50c1e02ab09b442ee34f20141018-34360-1kbemf6.MOV" -y "/var/folders/ys/wn_46zvs6jbgjvgnn45snf9m0000gn/T/dc5c7986daef50c1e02ab09b442ee34f20141018-34360-1kbemf620141018-34360-1615t53.jpg": Command 'ffmpeg -i "/var/folders/ys/wn_46zvs6jbgjvgnn45snf9m0000gn/T/dc5c7986daef50c1e02ab09b442ee34f20141018-34360-1kbemf6.MOV" -y "/var/folders/ys/wn_46zvs6jbgjvgnn45snf9m0000gn/T/dc5c7986daef50c1e02ab09b442ee34f20141018-34360-1kbemf620141018-34360-1615t53.jpg"' returned 1. Expected 0

FFMpeg install in different dir than ImageMagick

My ImageMagick is install in /usr/bin via yum
and my ffmpeg installed via script is in /user/local/bin' but Paperclip uses the samecommand_path` for both. is there a way we can fix this without moving the installations around.

Thanks

using this gem on Windows is not working Av::CommandError

Hi, this is my first issue posting on github, so please if I'm not doing something right, please tell me :)

OK, so we have one project that is working on Linux version of server on AWS, and I use Windows as a OS. When I want to create new attachment using this gem, I get following error:

**Av::CommandError in Api::V1::DigitalProductsController#create

error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 1. Expected 0 Here is the command output: STDOUT:

STDERR:
-v was unexpected at this time.**

_I'm reporting this as an issue, as gem is working fine on Linux, but on Windows it is not good. _

I have tried to do everything that others users reported similar problems, but without any success. Also, on stack or Google, there is no search result with my issue, like nobody has this problem :(

Please can you see if there is an issue for real, or there are some things that are too obvious that I have missed. I'm sending some screens just in order to have full picture.

Thank you.
call_error
call_error_2

ReadMe does not list Dependencies

Can we please have a list of dependencies this gem depends on. like ffmpeg

I get this error on uploading video.

LoadError (cannot load such file --/Users/SM/Developer/QBXNet/RoR/etracs/project/lib/paperclip_processors/transcoder.rb)

any other files needed. where do we get this file?

Post processing complete

I am trying to capture when the video transcoding has finished so I can notify the user about success or not, and to mark the transcoded video as ready to show on my site.

I have tried the capturing the "after__post_process" event but that is firing before the transcoding has finished.

Not sure if that is a bug or if I have to find another way to capture completion of the transcoding?

Cheers, James

CPU limit ffmpeg

Is there a way to limit the CPU usage when this gem starts up ffmpeg?

Just using the examples, ffmpeg will use 99% of the CPU making the rest of the app totally unresponsive.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.