Git Product home page Git Product logo

carrierwave-video's Issues

Are video files being saved at a later time frame than the initial commit?

When I attempt to commit an object into the database (postgres) I get video_file must not be blank. I'm using carrierwave-postgresql, carrierwave_backgrounder, streamio-ffmpeg, and postgresql_lo_streamer. When I use File.open('..') in Rails Console. It begins the encoding process immediately and follows through to completion. In other words, I can't create new records with Rails form_for. Have you experienced this problem before?

Rename gem?

This gem can also be very successfully used to encode audio. It may be a good idea to emphasise on that, rename the gem to carrierwave-ffmpeg and encode_video to either simply encode, encode_medium or dual encode_audio and encode_video being aliases.

What do you think? :)

FFmpeg fails when setting the resolution to :same

If i run apply :same as output resolution, there is output failure on the ffmpeg convert line, a ')' that shouldn't be there

(I've stripped file locations in the pasted text just to make it shorter)

  version :mp4 do
    process encode_video: [:mp4, resolution: :same]
  end
I, [2014-02-11T15:06:31.391521 #95985]  INFO -- : Running transcoding...
ffmpeg -y -i infile.mov -vcodec libx264 -acodec libfaac -s bt709)  -qscale 0 -preset slow -g 30 -aspect NaN tmpfile.mp4

sh: -c: line 0: syntax error near unexpected token `)'

When specifying a resolution it works as intended:

I, [2014-02-11T15:10:07.318938 #95985]  INFO -- : Running transcoding...
ffmpeg -y -i infile.mov -vcodec libx264 -acodec libfaac -s 852x480  -qscale 0 -preset slow -g 30 -aspect 1.775 tmpfile.mp4

Turned out that file.resolution in https://github.com/rheaton/carrierwave-video/blob/master/lib/carrierwave/video.rb#L48 actually returns "bt709)", so it's probably a streamio error.

Compatibility with streamio-ffmpeg 2.1.0

Hi,

After updating streamio-ffmpeg to the latest version 2.1.0, I get the following error.

CarrierWave::ProcessingError: Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: no implicit conversion of String into Array

Not processing transcoded video

In my Rails app, I'm transcoding video files to mp4, creating an image record from a thumbnail of the video (using carrierwave-video-thumbnailer), and storing both files on Amazon S3. According to my logs, the video is successfully transcoded to an mp4 file, but when a record is created for the video, it's still using the ".mov" file that was uploaded:

ffmpeg -y -i /Website/public/uploads/tmp/1380743030-66301-1674/Untitled.mov -vcodec libx264 -acodec libfaac -s 640x360 -qscale 0 -preset slow -g 30 -aspect 1.7777777777777777 /Website/public/uploads/tmp/1380743030-66301-1674/tmpfile.mp4

Transcoding of /Website/public/uploads/tmp/1380743030-66301-1674/Untitled.mov to /Website/public/uploads/tmp/1380743030-66301-1674/tmpfile.mp4 succeeded

Started POST "/videos" for 127.0.0.1 at 2013-10-02 15:43:50 -0400
Processing by VideosController#create as HTML
Parameters: {"utf8"=>"✓", "video"=>{"project_id"=>"4", "step_id"=>"23", "saved"=>"true", "embed_url"=>"", "video_path"=>#<ActionDispatch::Http::UploadedFile:0x007f89c4a4e0e8 @original_filename="Untitled.mov", @content_type="video/quicktime", @headers="Content-Disposition: form-data; name="video[video_path]"; filename="Untitled.mov"\r\nContent-Type: video/quicktime\r\n", @tempfile=#File:/var/folders/dc/c0nfvwy96lq7p4ll94mklnmr0000gp/T/RackMultipart20131002-66301-ty7ceo>}, "button"=>""}
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Project Load (0.3ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT 1 [["id", "4"]]
Running....ffmpegthumbnailer -i /Website/public/uploads/tmp/1380743442-66301-3112/thumb_Untitled.mov -o /Website/public/uploads/tmp/1380743442-66301-3112/tmpfile.png -c png -q 10 -s 158
Success!
(0.1ms) BEGIN
SQL (4.1ms) INSERT INTO "videos" ("created_at", "embed_url", "image_id", "project_id", "saved", "step_id", "thumbnail_url", "updated_at", "video_path") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id" [["created_at", Wed, 02 Oct 2013 15:50:44 EDT -04:00], ["embed_url", ""], ["image_id", nil], ["project_id", 4], ["saved", true], ["step_id", 23], ["thumbnail_url", nil], ["updated_at", Wed, 02 Oct 2013 15:50:44 EDT -04:00], ["video_path", "Untitled.mov"]]

How can I ensure that the transcoded video is the one being used to create the video record?

This is my video_path_uploader.rb file:

class VideoPathUploader < CarrierWave::Uploader::Base
include CarrierWave::Video
include CarrierWave::Video::Thumbnailer

process encode_video: [:mp4]

Include RMagick or MiniMagick support:

include CarrierWave::MiniMagick

Choose what kind of storage to use for this uploader:

storage :file

storage :fog

Override the directory where uploaded files will be stored.

This is a sensible default for uploaders that are meant to be mounted:

def store_dir
"#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

version :thumb do
process thumbnail: [{format: 'png', quality: 10, size: 158, logger: Rails.logger}]
def full_filename for_file
png_name for_file, "thumbnail"
end
end

def png_name for_file, version_name
Rails.logger.debug %Q{filename: #{version_name}#{for_file.chomp(File.extname(for_file))}.png}
%Q{#{version_name}
#{for_file.chomp(File.extname(for_file))}.png}
end
end

Failed to transcode with FFmpeg

Failed to transcode with FFmpeg.

Original error: nil is not a symbol\n/home/aeliseev/pecaa/shared/bundle/ruby/1.9.1/gems/carrierwave-video-0.5.2/lib/carrierwave/video.rb:89:in `rescue in with_trancoding_callbacks

Pull request with fix: #13

No way to set encoder options

There is encoder_options in CarrierWave::Video:: FfmpegOptions which is hardcoded to { preserve_aspect_ratio: :width }. But I want to set video size by height nad so I should change this to { preserve_aspect_ratio: :height }.

I think there should be a way to pass encoder options as other options.

No such filter: '"movie'

Hi to all, Actually I am trying to insert watermark in the video by using carrierwave-video gem but when I run the command with watermark options it throws me error "No such filter: '"movie'". And when I remove watermark option it runs perfectly. Could anyone tell me where is the actual problem?

No way not to send -s option ?

encode_video use a default resolution if there isn't any specified (definition option).
How to encode without the -s option ?

scaling not work

hi
i am using this gem for my video process and i want to scale my video to different size, but the output not change and all my version have same video size and resolution
this is my code:
`class MediaUploader < CarrierWave::Uploader::Base

encoding: utf-8

include CarrierWave::Video  # for your video processing
include CarrierWave::Video::Thumbnailer
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MimeTypes
require 'rubygems'
require 'streamio-ffmpeg'


process encode_video: [:mp4, audio_codec: "aac", custom: "-strict experimental -q:v 5 -preset slow -g 30 -movflags faststart",
  callbacks: { after_transcode: :set_success } ], :if => :video?

version :thumb do
  process thumbnail: [{format: 'png', quality: 10, size: 710, logger: Rails.logger}]
  def full_filename for_file
    png_name for_file, version_name
  end
end

version :mp4 do
  process encode_video: [:mp4, audio_codec: "aac", custom: "-strict experimental -q:v 5 -preset slow -g 30 -movflags faststart",
    callbacks: { after_transcode: :set_success } ], :if => :video?
  def full_filename for_file
    mp4_name for_file, version_name
  end
end
version :mid_mp4 do
  process encode_video: [:mp4, audio_codec: "aac", custom: "-vf scale=-1:360 -strict experimental -q:v 5 -preset slow -g 30 -movflags faststart",
    callbacks: { after_transcode: :set_success } ], :if => :video?
  def full_filename for_file
    mp4_name_mid for_file, version_name
  end
end`

video files are not processing on commit

For some odd reason, I can only transcode/process videos in rails console. Do you have an idea of why that might be happening in my development environment? It doesn't even start to transcode when the record is being inserted into the database. It saves both the video column and video_processing column as null. FFMPEG works without issue in my command prompt. I'm using Postgresql and Rails 5.2, btw.

Started POST "/stories" for 127.0.0.1 at 2018-09-18 16:23:18 -0400
Processing by StoriesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"HvKj2C5PZzS4sMS1B1izjlpzoOkTTwuaxleHoFdU9PFakGjOP7NeE0qKfBjyaL+Hv5awE9NJxrW1WDvs5S/zEA==", "story"=>{"story_title"=>"Hi, I'm testing the story feature", "story_body"=>"Ummm", "story_private"=>"0", "show_story_location"=>"1"}, "..."=>#<ActionDispatch::Http::UploadedFile:0x000000000f7c5470 @tempfile=#<Tempfile:C:/Users/Coder/AppData/Local/Temp/RackMultipart20180918-11600-1h75hr1.mp4>, @original_filename="02_01-Theory Outline.mp4", @content_type="video/mp4", @headers="Content-Disposition: form-data; name=\"...\"; filename=\"02_01-Theory Outline.mp4\"\r\nContent-Type: video/mp4\r\n">, "commit"=>"Create Story"}
  User Load (8.0ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 2], ["LIMIT", 1]]
   (1.0ms)  BEGIN
  Story Create (341.8ms)  INSERT INTO "stories" ("story_title", "story_body", "story_private", "user_id", "created_at", "updated_at", "show_story_location") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["story_title", "Hi, I'm testing the story feature"], ["story_body", "Ummm"], ["story_private", false], ["user_id", 2], ["created_at", "2018-09-18 20:23:23.717774"], ["updated_at", "2018-09-18 20:23:23.717774"], ["show_story_location", true]]
   (1.0ms)  COMMIT
Redirected to http://127.0.0.1:3000/stories/22
Completed 302 Found in 799ms (ActiveRecord: 388.8ms)

Unable to process video

Hi there, I am trying to process MP4 video to video with different resolution. There is used custom parameter.

Parameters for processing:
process encode_video: [:mp4, :resolution => "1280x720", :custom => "-pix_fmt yuv420p"]

There is an error that slow profile wasn't found.

Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: Failed encoding. Errors: no output file created. Full output: ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 24 2012 17:41:42 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
configuration: --prefix=/usr/local/Cellar/ffmpeg/0.11.1 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-libfreetype --cc=/usr/bin/llvm-gcc --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-libvo-aacenc --disable-ffplay
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/milan/github/lettr/tmp/uploads/20120809-0843-3534-7339/M4H00620.MP4':
Metadata:
major_brand : MSNV
minor_version : 19595353
compatible_brands: MSNVmp42isom
creation_time : 2010-08-21 17:37:22
Duration: 00:00:33.53, start: 0.000000, bitrate: 8908 kb/s
Stream #0:0(und): Video: mpeg4 (Advanced Coding Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 8842 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc
Metadata:
creation_time : 2010-08-21 17:37:22
handler_name : Video Media Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 24000 Hz, mono, s16, 64 kb/s
Metadata:
creation_time : 2010-08-21 17:37:22
handler_name : Sound Media Handler
Please use -q:a or -q:v, -qscale is ambiguous
File for preset 'slow' not found

store multiple quality

hi guys
i want store multiple quality of video like 1080p, 720p, 360p,480p
how can i do this action (like youtube) ?

Background jobs support

Hi,

Video converting sometimes takes a long time. So is it possible to combine background jobs support like Sidekiq, Resque or Delayed Job with your gem?

Error while converting video

Hi, converting video, I get this error.
"Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: nil is not a symbol"

Processing by VideosController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wdtk1Fq+9ZrR+YwNtwzDKIcEb3xa1YkySme+suXyCe8=", "video"=>{"name"=>"test", "file"=>#<ActionDispatch::Http::UploadedFile:0x00000004d95ef0 @tempfile=#Tempfile:/tmp/RackMultipart20130814-3358-1ozzuwy, @original_filename="t.A.T.u. - 220 (RU).flv", @content_type="video/x-flv", @headers="Content-Disposition: form-data; name="video[file]"; filename="t.A.T.u. - 220 (RU).flv"\r\nContent-Type: video/x-flv\r\n">, "remove_file"=>"0"}, "commit"=>"Создать Video"}
I, [2013-08-14T21:43:01.683178 #3358] INFO -- : Running transcoding...
ffmpeg -y -i /home/vadim/work/MichelinRails/public/uploads/tmp/1376505781-3358-1561/t.A.T.u._-220__RU.flv -vcodec libx264 -acodec libfaac -s 640x480 -qscale 0 -preset slow -g 30 -aspect 1.3333333333333333 /home/vadim/work/MichelinRails/public/uploads/tmp/1376505781-3358-1561/tmpfile.mp4

set uploaded video length limit

After setup the carrier-wave video, i noticed that after upload the video the gem has a after_transcode: :set_success callback. that seems possible to configure.

I would like to know if by carrierwave is possible to set the video lenght after or before the transcoding by carrierwave.

Because in the docs seems that don't have mention to that.

after_transcoding callback called too soon

I'm using the after_transcoding callback in a method of an uploader for a version of a video file:

def encode
    video = MiniExiftool.new(@file.path)

    aspect_ratio = video.imagewidth.to_f / video.imageheight.to_f
    encode_video(:mp4, resolution: "640x360", aspect: aspect_ratio, audio_codec: "aac", custom: "-strict -2 -b:a 32k", callbacks: { after_transcoding: :set_status })

    instance_variable_set(:@content_type, "video/mp4")
    :set_content_type_mp4
  end

  version :encoded_video do
    process :encode
  end

def set_content_type_mp4(*args)
    self.file.instance_variable_set(:@content_type, "video/mp4")
  end

that hits another method in a model to set a field:

def set_status(format, opts)
      self.update_column(:status, "active")
end

But the callback is being hit before transcoding is complete and the status field is active before the transcoding is complete.

I'm using:

carrierwave (~> 0.10.0)
carrierwave-video (0.5.6)
and ruby 2.2.3.

Errno::ENOENT, No such file or directory - ffmpeg -i path_public/uploads/tmp/1414501164-5614-4315/video1.mp4 , Error while uploading File.

Hi,
Before I ask anythink I just want to say I'm very new to rails.
I'm building an application where users can upload a video. Using carrierwave i could upload the video successfully but html5 video tag doeant work for all video formats. On looking around I found this gem. I followed the instructions but I'm getting the following error.

Errno::ENOENT in VideosController#create
No such file or directory - ffmpeg -i path_public/uploads/tmp/1414501164-5614-4315/video1.mp4

I don't know what is going wrong.

My storage path is the default path given by carrierwave which is
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"

but I don't know why it is looking for a path_public/uploads/tmp/1414501164-5614-4315/video1.mp4.

Can someone please help me?

set content type for versions

I'm trying to upload different version of a video file to Amazon S3 using carrierwave-video. I'm able to create mp4 and webm videos, but the content type is set to "video/quicktime" for both files rather than their respective filetypes.

I tried adding

require 'carrierwave/processing/mime_types'
include CarrierWave::MimeTypes

and then "process :set_content_type" for each version, but it still doesn't save the different content types on Amazon S3.

Video Orientation Incorrect

I have a video that is 1080 x 1920. When it gets uploaded via carrierwave-video, the video appears to be rotated 90 degrees counter-clockwise. How can I ensure that the video is not rotated? What types of methods can I use to detect the video's dimensions when the user uploads the file?

This is only an issue when uploading portrait videos.

Screenshot thumbnail

Hi,

I was wondering it it would be difficult to add thumbnail creation functionality to the library? I know FFMPEG has screenshot capability but I have yet been unable to get it to generate a thumbnail correctly.

Thanks,
Chris

Error when processing webm

I'm getting the following error when I'm trying to create a webm version of a video file:

Running transcoding...
ffmpeg -y -i /public/uploads/tmp/1382112521-11953-7661/webm_Untitled.mov -vcodec libvpx -acodec libvorbis -s 640x360 -b 1500k -ab 160000 -f webm -g 30 -aspect 1.7777777777777777 /public/uploads/tmp/1382112521-11953-7661/tmpfile.webm

Failed encoding...
ffmpeg -y -i /public/uploads/tmp/1382112521-11953-7661/webm_Untitled.mov -vcodec libvpx -acodec libvorbis -s 640x360 -b 1500k -ab 160000 -f webm -g 30 -aspect 1.7777777777777777 /public/uploads/tmp/1382112521-11953-7661/tmpfile.webm

ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Sep 27 2013 14:00:31 with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libvpx
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/public/uploads/tmp/1382112521-11953-7661/webm_Untitled.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2013-09-27 20:08:57
Duration: 00:00:02.14, start: 0.000000, bitrate: 17460 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17292 kb/s, 29.88 fps, 29.83 tbr, 90k tbn, 180k tbc
Metadata:
creation_time : 2013-09-27 20:08:57
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s
Metadata:
creation_time : 2013-09-27 20:08:57
handler_name : Core Media Data Handler
Please use -b:a or -b:v, -b is ambiguous
Unknown encoder 'libvorbis'

Here is what I have in my uploader:

version :webm do
process :encode_video => [:webm]
def full_filename(for_file)
"#{File.basename(for_file, File.extname(for_file))}.webm"
end
end

I have libvorbis-1.3.3 installed on my machine.

Failed to transcode with FFmpeg

I got error "Completed 422 Unprocessable Entity, ActiveRecord::RecordInvalid (Validation failed: Source Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: ArgumentError)" anyone can help?

ffmpeg fails when creating version wihtout watermark

I'm trying to convert a mp4 movie to a webm version using

version :webm do
    process encode_video: :webm
end

However, that fails when not providing a watermark, cause ffmpeg get's double inputs.

E, [2014-02-11T18:15:51.590871 #13143] ERROR -- : Failed encoding...
ffmpeg -y -i webm_homepage-featured-video.mp4 -vcodec libvpx -acodec libvorbis -s 640x360 -i {} -b 1500k -ab 160000 -f webm -g 30 -aspect 1.7777777777777777 tmpfile.webm

{}: No such file or directory
Errors: no output file created.

Running the same version with a watermark set to nil, it works fine

version :webm do
  process encode_video: [:webm, { watermark: nil } ]
end

It's probably due to the default empty hash that get set as a default value on initialize:
https://github.com/mattiasottosson/carrierwave-video/blob/master/lib/carrierwave/video/ffmpeg_options.rb#L-78

Failed to set value '0' for option qscale

I have a test file downloaded from

http://www.youtube.com/watch?v=C0DPdy98e4c

and saved as a webm and flv using Flash Video Downloader. The files are named test.flv and test.webm. When testing my model, I get transcoding errors from ffmpeg.

  1. It says ffmpeg is being deprecated in favour of avconv.

  2. Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)

  3. qscale must be > 0.0 and <= 255

  4. Failed to set value '0' for option 'qscale'

ffmpeg reports version 0.8.10-6.0.8.10-0ubuntu0.13.10.1

These issues occur for both the flv and webm files. I also did another test with an .avi file downloaded from the web (not using FLV downloader) and I also get these issues.

Successfully converted file is not moved from cache to the actual storage directory.

The successfully converted file is not being moved from cache to actual storage directory.

Rails version: 6.1.3.1
Ruby version: 2.6

Steps:

  • Let's say file_name.mov (non-mp4) file is uploaded.
  • It's encoded into mp4 through carrierwave::video and ffmpeg.
  • conversion is successfully completed.
  • the file is in the cache directory as file_name.mp4 and the file plays and works correctly.
  • file_name.mov in the storage directory is never removed or replaced with the mp4 file.
  • mp4 file stays in the cache file forever even after the conversion is done.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Transcoding passes but video not uploaded (rollback transaction)

I am using Rails 4.2. I have a ContentUploader for uploading images and videos. I am using carrierwave-video-thumbnailer for creating video thumbnails.

  version :mp4, :if => :video? do
    process encode_video: [:mp4, callbacks: { after_transcode: :set_is_converted } ]
  end

Following is the output:

Started POST "/contents" for ::1 at 2015-06-28 18:58:37 +0900
Processing by ContentsController#create as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"7RkO8vRffeyY2/17fOKdmTa3EltgVBhYUu0opaS3mu7YYjrY3XRcwKgvcXdm/7QbQw7x+uh5eXrvTFVMtdcj1Q==", "content"=>{"description"=>"video avi", "file"=>#<ActionDispatch::Http::UploadedFile:0x007f9be644fa28 @tempfile=#<Tempfile:/var/folders/jb/hs3mvqg55plf3dhm08wc94sw0000gn/T/RackMultipart20150628-83235-19tgkw3.avi>, @original_filename="dfs.avi", @content_type="video/avi", @headers="Content-Disposition: form-data; name=\"content[file]\"; filename=\"dfs.avi\"\r\nContent-Type: video/avi\r\n">}}
Running....ffmpegthumbnailer -i /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/vthumb_dfs.avi -o /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/tmpfile.png -c png -q 10 -s 192 -f
Success!
I, [2015-06-28T18:58:38.117063 #83235]  INFO -- : Running transcoding...
ffmpeg -y -i /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/mp4_dfs.avi -vcodec libx264 -acodec libfaac -s 640x480 -qscale 0 -preset slow -g 30  -aspect 1.3333333333333333 /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/tmpfile.mp4

I, [2015-06-28T18:58:39.494630 #83235]  INFO -- : Transcoding of /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/mp4_dfs.avi to /Users/zeronone/myfiles/projects/coe/coe_control_center/webapp/public/uploads/tmp/1435485517-83235-1521/tmpfile.mp4 succeeded

  �[1m�[36m (0.1ms)�[0m  �[1mbegin transaction�[0m
  �[1m�[35m (0.0ms)�[0m  rollback transaction
  Rendered contents/create.js.erb (0.9ms)

Aspect ratio distorted with newer Samsung Galaxy videos

After upgrading a Samsung Galaxy phone, all my newer videos made in portrait mode have the wrong aspect ratio after transcoding (any target format), e.g.:

preview_20170531_114221

I have a fix that works for my videos now:

  1. I've forked the Gem and removed the default resolution (640x360) and preserve_aspect_ratio attributes (:width), as those interfer with the solution
  2. I've replaced the resizing with a decrease as written in the ffmpeg docs in the last paragraph here (https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg)
  3. When transcoding a video, I've moved the resolution parameters together with the solution in the custom block, as otherwise streamio-ffmpeg will add a nasty aspect-param that distorts the image again
# old video->jpg
# process encode_video: [:jpg, resolution: '500x500', preserve_aspect_ratio: :width]
process encode_video: [:jpg, custom: '-vf scale=w=500:h=500:force_original_aspect_ratio=decrease']

# old video->mp4
# process encode_video: [:mp4, resolution: '640x360', preserve_aspect_ratio: :width, audio_codec: 'aac']
process encode_video: [:mp4, custom: '-s 640x360 -vf scale=w=640:h=360:force_original_aspect_ratio=decrease', audio_codec: 'aac']

I am aware, that Carrierwave Video can't do to much but just change the default resolution/preserve_aspect_ratio params to allow override. There seem to be a problem in combination with the streamio-ffmpeg Gem. Just leaving this here to help other people with the same problem!

Difference between Samsung's meta data: I've compared a "new" and a "old" video. Most params are similar, but one stood out.

It seems, that the old format didn't specify the aspect ratio, but the new one specify it:

// NEW format (output from ffprobe)
{
    ///...
    "sample_aspect_ratio": "1:1",                                                              
    "display_aspect_ratio": "16:9",
}

// OLD format (output from ffprobe)
{
    ///...
    "sample_aspect_ratio": "0:1",
    "display_aspect_ratio": "0:1",
}

Failed to transcode with FFmpeg

Hi,

I am having this error:

Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: ArgumentError

I think i have ffmpeg working correctly, ive already checked it.

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.