Project

rtrack

0.0
No commit activity in last 3 years
No release in over 3 years
RTrack is a object-oriented wrapper around ffmpeg to manipulate audiofiles easily from ruby code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 0
 Project Readme

Rtrack Build Status

RTrack is an object-oriented wrapper around ffmpeg to manipulate audiofiles easily from ruby code.

Installation

Add this line to your application's Gemfile:

gem 'rtrack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rtrack

Usage

Open a wave file

require 'rtrack'

song = AudioTrack.from_file "never_gonna_give_you_up.wav"

...or a mp3 file

require 'rtrack'

song = AudioTrack.from_file "never_gonna_give_you_up.mp3"

... or an ogg, or flv, or anything else ffmpeg supports

ogg_version = AudioTrack.from_file "never_gonna_give_you_up.ogg"
flv_version = AudioTrack.from_file "never_gonna_give_you_up.flv"
mp4_version = AudioTrack.from_file "never_gonna_give_you_up.mp4"
wma_version = AudioTrack.from_file "never_gonna_give_you_up.wma"
aac_version = AudioTrack.from_file "never_gonna_give_you_up.aiff"

You can concatenate multiple AudioTracks together

song_one = AudioTrack.from_file "one_love.mp3"
song_two = AudioTrack.from_file "jamming.ogg"

song_three = song_one + song_two

song_four = song_one + song_two + song_three + AudioTrack.from_file "buffallo_soldiers.mp3"

Get a slice of a track, first 10 seconds

song = AudioTrack.from_file "mozart.mp3"
slice = song[10000] # rtrack works on milliseconds

Wonder how long is that song?

song = AudioTrack.from_file "jamming.mp3"
puts song.seconds

Repeat track 4 times

beat = AudioTrack.from_file "beat.wav"
remix = beat * 4

Save the result to disk

remix.export "remix.mp3", "mp3"
# or
remix.save "remix.mp3", "mp3"

Save the results with bitrate

remix.export "remix.mp3", "mp3", "192k"

Examples

Let's suppose you have plenty of mp4 videos that you'd like to convert to mp3 so you can listen on your mp3 player on the road.

require "rtrack"

Dir[Dir.home + "/Videos/*.mp4"].each do |video_path|
  video_name = File.basename(video_path, File.extname(video_path))
  puts "converting #{video_name}"
  song = AudioTrack.from_file video_path
  song.export "#{video_name}.mp3"
end

Dependencies

Requires ffmpeg or avconv for encoding and decoding.

-OR-

Trivia

  • RTrack is inspired by pydub and jquery
  • As in pydub all AudioTrack objects are immutable
  • As in jquery you can chain operations using AudioTrack objects

Contributing

  1. Fork it ( http://github.com/marcwebbie/rtrack/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 new Pull Request