zencoder / rvideo Goto Github PK
View Code? Open in Web Editor NEWOfficial home of the RVideo project, a Ruby gem for video and audio transcoding.
License: MIT License
Official home of the RVideo project, a Ruby gem for video and audio transcoding.
License: MIT License
RVideo RVideo allows you to inspect and process video files. Installation is a little involved. First, install the gem: sudo gem install rvideo Next, install ffmpeg and (possibly) other related libraries. This is documented elsewhere on the web, and can be a headache. If you are on OS X, the Darwinports build is reasonably good (though not perfect). Install with: sudo port install ffmpeg Or, for a better build (recommended), add additional video- and audio-related libraries, like this: sudo port install ffmpeg +lame +libogg +vorbis +faac +faad +xvid +x264 +a52 Most package management systems include a build of ffmpeg, but many include a poor build. So you may need to compile from scratch. If you want to create Flash Video files, also install flvtool2: sudo gem install flvtool2 Once ffmpeg and RVideo are installed, you're set. To inspect a file, initialize an RVideo file inspector object. See the documentation for details. A few examples: file = RVideo::Inspector.new(:file => "#{APP_ROOT}/files/input.mp4") file = RVideo::Inspector.new(:raw_response => @existing_response) file = RVideo::Inspector.new(:file => "#{APP_ROOT}/files/input.mp4", :ffmpeg_binary => "#{APP_ROOT}/bin/ffmpeg") file.fps # "29.97" file.duration # "00:05:23.4" To transcode a video, initialize a Transcoder object. transcoder = RVideo::Transcoder.new Then pass a command and valid options to the execute method recipe = "ffmpeg -i $input_file$ -ar 22050 -ab 64 -f flv -r 29.97 -s" recipe += " $resolution$ -y $output_file$" recipe += "\nflvtool2 -U $output_file$" begin transcoder.execute(recipe, {:input_file => "/path/to/input.mp4", :output_file => "/path/to/output.flv", :resolution => "640x360"}) rescue TranscoderError => e puts "Unable to transcode file: #{e.class} - #{e.message}" end If the job succeeds, you can access the metadata of the input and output files with: transcoder.original # RVideo::Inspector object transcoder.processed # RVideo::Inspector object If the transcoding succeeds, the file may still have problems. RVideo will populate an errors array if the duration of the processed video differs from the duration of the original video, or if the processed file is unreadable. Thanks to Peter Boling for early work on RVideo. Contribute to RVideo! If you want to help out, there are a few things you can do. - Use, test, and submit bugs/patches - We need a RVideo::Tools::Mencoder class to add mencoder support. - Other tool classes would be great - On2, mp4box, Quicktime (?), etc. - Submit other fixes, features, optimizations, and refactorings If RVideo is useful to you, you may also be interested in RMovie, another Ruby video library. See http://rmovie.rubyforge.org/ for more. Finally, watch for Zencoder, a commercial video transcoder built by Slantwise Design. Zencoder uses RVideo for its video processing, but adds file queuing, distributed transcoding, a web-based transcoder dashboard, and more. See http://zencoder.tv or http://slantwisedesign.com for more. Copyright (c) 2007 Jonathan Dahl and Slantwise Design. Released under the MIT license.
I cannot get the Inspector to work in the slightest. I dropped a sample video in my root directory and did the following
irb(main):002:0> system("ffmpeg -i ~/temp.mov")
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:52:09 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x206c7a0] multiple edit list entries, a/v desync might occur, patch welcome
Seems stream 1 codec frame rate differs from container frame rate: 1200.00 (1200/1) -> 57.08 (685/12)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vagrant/temp.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2012-05-24 01:29:54
Duration: 00:00:15.62, start: 0.000000, bitrate: 1177 kb/s
Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16, 96 kb/s
Metadata:
creation_time : 2012-05-24 01:29:54
Stream #0.1(und): Video: h264 (Main), yuv420p, 720x480 [PAR 1:1 DAR 3:2], 1066 kb/s, 13.67 fps, 57.08 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2012-05-24 01:29:54
At least one output file must be specified
=> false
But when I try using rvideo:
irb(main):004:0> RVideo::Inspector.new(:ffmpeg_binary => "/usr/bin/ffmpeg", :file => "/home/vagrant/temp.mov").container
=> nil
irb(main):005:0> RVideo::Inspector.new(:ffmpeg_binary => "/usr/bin/ffmpeg", :file => "/home/vagrant/temp.mov").duration
=> nil
irb(main):006:0> RVideo::Inspector.new(:ffmpeg_binary => "/usr/bin/ffmpeg", :file => "/home/vagrant/temp.mov").fps
=> nil
rvideo 0.9.3
ffmpeg 0.8.3-4:0.8.3-0ubuntu0.12.04.1
Running on Ubuntu 12.04 in a vagrant vm.
It appears that different versions of ffmpeg output information in slightly different ways. The ffmpeg from macports will fail to encode any videos because of this. There is a simple patch you can find at http://github.com/mhs/rvideo/tree/ffmpegfix
We didn't notice you had pushed to github originally so we pushed out a mhs-rvideo gem. If you can include this patch we'll take our gem down and move back to your rvideo gem. Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.