Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [master, relatel]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ['3.3', '3.4', '4.0', 'head']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install ffmpeg
run: sudo apt-get update && sudo apt-get install -y ffmpeg

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Run tests
run: bundle exec rake
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-4.0.1
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

12 changes: 11 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
== Master

Current with 3.0.2
Breaking Changes:
* Require Ruby >= 3.3
* Removed multi_json dependency — uses stdlib JSON
* Removed IO monkey patch — timeout handling is now private to Transcoder
* transcode/screenshot now accept keyword arguments for transcoder_options

Improvements:
* GitHub Actions CI replacing Travis
* Fixed rotation detection for modern ffmpeg (side_data_list)
* Fixed SSL detection (scheme instead of port)
* General Ruby 3.x/4.0 compatibility fixes

== 3.0.2 2016-11-18

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec

group :test do
gem 'webmock'
gem 'simplecov'
end
gem 'webrick'
gem 'webmock'
gem 'rspec'
gem 'rake'
42 changes: 12 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
Streamio FFMPEG
===============

[![Build Status](https://travis-ci.org/bikeath1337/streamio-ffmpeg.svg?branch=master)](https://travis-ci.org/bikeath1337/streamio-ffmpeg)
[![Code Climate](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/badges/gpa.svg)](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg)
[![Test Coverage](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/badges/coverage.svg)](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/coverage)

Simple yet powerful wrapper around the ffmpeg command for reading metadata and transcoding movies.

All work on this project is sponsored by the online video platform [Streamio](https://streamio.com) from [Rackfish](https://www.rackfish.com).

[![Streamio](http://d253c4ja9jigvu.cloudfront.net/assets/small-logo.png)](https://streamio.com)

Installation
------------

Expand All @@ -21,17 +15,11 @@ Compatibility

### Ruby

Only guaranteed to work with MRI Ruby 1.9.3 or later.
Should work with rubinius head in 1.9 mode.
Will not work in jruby until they fix: http://goo.gl/Z4UcX (should work in the upcoming 1.7.5)
Requires Ruby 3.3 or later.

### ffmpeg

The current gem is tested against ffmpeg 2.8.4. So no guarantees with earlier (or much later)
versions. Output and input standards have inconveniently changed rather a lot between versions
of ffmpeg. My goal is to keep this library in sync with new versions of ffmpeg as they come along.

On macOS: `brew install ffmpeg`.
Should work with any modern ffmpeg. Install with your package manager, e.g. on macOS: `brew install ffmpeg`.

Usage
-----
Expand Down Expand Up @@ -127,11 +115,9 @@ widescreen_movie = FFMPEG::Movie.new("path/to/widescreen_movie.mov")

options = { resolution: "320x240" }

transcoder_options = { preserve_aspect_ratio: :width }
widescreen_movie.transcode("movie.mp4", options, transcoder_options) # Output resolution will be 320x180
widescreen_movie.transcode("movie.mp4", options, preserve_aspect_ratio: :width) # Output resolution will be 320x180

transcoder_options = { preserve_aspect_ratio: :height }
widescreen_movie.transcode("movie.mp4", options, transcoder_options) # Output resolution will be 426x240
widescreen_movie.transcode("movie.mp4", options, preserve_aspect_ratio: :height) # Output resolution will be 426x240
```

For constant bitrate encoding use video_min_bitrate and video_max_bitrate with buffer_size.
Expand All @@ -143,29 +129,26 @@ movie.transcode("movie.flv", options)

### Specifying Input Options

To specify which options apply the input, such as changing the input framerate, use `input_options` hash
in the transcoder_options.
To specify which options apply the input, such as changing the input framerate, use `input_options` keyword argument.

``` ruby
movie = FFMPEG::Movie.new("path/to/movie.mov")

transcoder_options = { input_options: { framerate: '1/5' } }
movie.transcode("movie.mp4", {}, transcoder_options)
movie.transcode("movie.mp4", {}, input_options: { framerate: '1/5' })

# FFMPEG Command will look like this:
# ffmpeg -y -framerate 1/5 -i path/to/movie.mov movie.mp4
```

### Overriding the Input Path

If FFMPEG's input path needs to specify a sequence of files, rather than a path to a single movie, transcoding_options
`input` can be set. If this option is present, the path of the original movie will not be used.
If FFMPEG's input path needs to specify a sequence of files, rather than a path to a single movie, the
`input` keyword argument can be set. If this option is present, the path of the original movie will not be used.

``` ruby
movie = FFMPEG::Movie.new("path/to/movie.mov")

transcoder_options = { input: 'img_%03d.png' }
movie.transcode("movie.mp4", {}, transcoder_options)
movie.transcode("movie.mp4", {}, input: 'img_%03d.png')

# FFMPEG Command will look like this:
# ffmpeg -y -i img_%03d.png movie.mp4
Expand Down Expand Up @@ -244,7 +227,7 @@ slideshow = slideshow_transcoder.run
Specify the path to ffmpeg
--------------------------

By default, the gem assumes that the ffmpeg binary is available in the execution path and named ffmpeg and so will run commands that look something like `ffmpeg -i /path/to/input.file ...`. Use the FFMPEG.ffmpeg_binary setter to specify the full path to the binary if necessary:
By default, the gem finds the ffmpeg binary from your PATH. Use the FFMPEG.ffmpeg_binary setter to specify the full path to the binary if necessary:

``` ruby
FFMPEG.ffmpeg_binary = '/usr/local/bin/ffmpeg'
Expand Down Expand Up @@ -272,14 +255,13 @@ Disabling output file validation

By default Transcoder validates the output file, in case you use FFMPEG for HLS
format that creates multiple outputs you can disable the validation by passing
`validate: false` to transcoder_options.
`validate: false`.

Note that transcode will not return the encoded movie object in this case since
attempting to open a (possibly) invalid output file might result in an error being raised.

```ruby
transcoder_options = { validate: false }
movie.transcode("movie.mp4", options, transcoder_options) # returns nil
movie.transcode("movie.mp4", options, validate: false) # returns nil
```

Copyright
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RSpec::Core::RakeTask.new('spec') do |t|
t.pattern = FileList['spec/**/*_spec.rb']
end

task :default => :spec
task default: :spec

desc "Push a new version to Rubygems"
task :publish do
Expand Down
7 changes: 4 additions & 3 deletions lib/ffmpeg/encoding_options.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module FFMPEG
class EncodingOptions < Hash
def initialize(options = {})
Expand Down Expand Up @@ -26,7 +28,7 @@ def to_a
keys.sort_by{|k| params_order(k) }.each do |key|

value = self[key]
a = send("convert_#{key}", value) if value && supports_option?(key)
a = send(:"convert_#{key}", value) if value && supports_option?(key)
params += a unless a.nil?
end

Expand All @@ -44,8 +46,7 @@ def height

private
def supports_option?(option)
option = RUBY_VERSION < "1.9" ? "convert_#{option}" : "convert_#{option}".to_sym
private_methods.include?(option)
respond_to?(:"convert_#{option}", true)
end

def convert_aspect(value)
Expand Down
2 changes: 2 additions & 0 deletions lib/ffmpeg/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module FFMPEG
class Error < StandardError
end
Expand Down
42 changes: 0 additions & 42 deletions lib/ffmpeg/io_monkey.rb

This file was deleted.

Loading
Loading