From 2b0af9dbaf8f0cda24d2c91e1f1a26f83a20ccb4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Thu, 4 Jun 2015 10:13:46 +0300 Subject: [PATCH 1/5] Fix typo --- lib/paperclip/paperclip_processors/transcoder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/paperclip/paperclip_processors/transcoder.rb b/lib/paperclip/paperclip_processors/transcoder.rb index 01ee8d4..36b3f88 100755 --- a/lib/paperclip/paperclip_processors/transcoder.rb +++ b/lib/paperclip/paperclip_processors/transcoder.rb @@ -48,7 +48,7 @@ def make dst.binmode if @meta - log "Transocding supported file #{@file.path}" + log "Transcoding supported file #{@file.path}" @cli.add_source(@file.path) @cli.add_destination(dst.path) @cli.reset_input_filters From 1c9c74136016044bdc9a95db35d078a05b95ea84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Costa?= Date: Sun, 13 Dec 2015 22:34:58 +0000 Subject: [PATCH 2/5] Readds auto-rotate option --- lib/paperclip/paperclip_processors/transcoder.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/paperclip/paperclip_processors/transcoder.rb b/lib/paperclip/paperclip_processors/transcoder.rb index 36b3f88..d191ce6 100755 --- a/lib/paperclip/paperclip_processors/transcoder.rb +++ b/lib/paperclip/paperclip_processors/transcoder.rb @@ -56,6 +56,18 @@ def make if output_is_image? @time = @time.call(@meta, @options) if @time.respond_to?(:call) @cli.filter_seek @time + + if @auto_rotate && !@meta[:rotate].nil? + log "Adding rotation #{@meta[:rotate]}" + case @meta[:rotate] + when 90 + @convert_options[:output][:vf] = "'transpose=1'" + when 180 + @convert_options[:output][:vf] = "'vflip, hflip'" + when 270 + @convert_options[:output][:vf] = "'transpose=2'" + end + end end if @convert_options.present? From 98783a03641d143605e7d88382e0f077048c21e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Costa?= Date: Mon, 14 Dec 2015 12:01:29 +0000 Subject: [PATCH 3/5] Uses av filter_rotate instead --- lib/paperclip/paperclip_processors/transcoder.rb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/paperclip/paperclip_processors/transcoder.rb b/lib/paperclip/paperclip_processors/transcoder.rb index d191ce6..d67efea 100755 --- a/lib/paperclip/paperclip_processors/transcoder.rb +++ b/lib/paperclip/paperclip_processors/transcoder.rb @@ -56,18 +56,7 @@ def make if output_is_image? @time = @time.call(@meta, @options) if @time.respond_to?(:call) @cli.filter_seek @time - - if @auto_rotate && !@meta[:rotate].nil? - log "Adding rotation #{@meta[:rotate]}" - case @meta[:rotate] - when 90 - @convert_options[:output][:vf] = "'transpose=1'" - when 180 - @convert_options[:output][:vf] = "'vflip, hflip'" - when 270 - @convert_options[:output][:vf] = "'transpose=2'" - end - end + @cli.filter_rotate @meta[:rotate] if @auto_rotate && !@meta[:rotate].nil? end if @convert_options.present? From 47081726a92f1170a473b314e36e81e4cd9b8d46 Mon Sep 17 00:00:00 2001 From: Erik Rothoff Andersson Date: Thu, 4 Feb 2016 08:57:48 +0100 Subject: [PATCH 4/5] Show convert_options in README --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eda9480..062fb1e 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,35 @@ This will produce: You may optionally add `_meta` to your model and it will get populated with information about the processed video. -The geometry parameters are: +### `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](https://ffmpeg.org/ffmpeg.html). + +For example, sending in the `-an` flag would look like this: + +```ruby +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 ) From 4aec85e791ad1a62ea04dcef50d9b1bc10059736 Mon Sep 17 00:00:00 2001 From: Jeremy Clemans Date: Thu, 21 Apr 2016 21:10:04 -0700 Subject: [PATCH 5/5] Adds more detailed instructions on how to get file meta data --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 062fb1e..6a2673c 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,17 @@ 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. -You may optionally add `_meta` to your model and it will get populated with information about the processed video. +### Meta Data + +Then paperclip-av-transcoder can optionally add uploaded file meta data to a database column for `_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`