Project

chapter

0.0
No commit activity in last 3 years
No release in over 3 years
This very simple gem uses the mp4v2 C library to read and set the chapters of mp4 files.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.4
~> 3.12
 Project Readme

#Chapter#

Chapter is a simple gem to set mp4 chapter information.

Prerequisites

To use it, you'll need mp4v2 installed on your system.

On OS X:

brew install mp4v2

On FreeBSD:

cd /usr/ports/multimedia/mp4v2 && make install clean

On other systems you might need to compile it yourself. Please refer to the mp4v2 documentation on how to do that. ##Installation## Via Rubygems:

gem install chapter

Or add the gem to your Gemfile:

gem 'chapter'

Usage

Read the chapters of a file

require 'chapter'
chapters = Chapter.chapters('/path/to/file.m4a')

chapters will be an array of hashes. Each hash represents a chapter with its position and duration (both in microseconds) and its title. ####Example

[
  {"title"=>"Introduction", "duration"=>12325, "position"=>0},
  {"title"=>"Discussion", "duration"=>655325, "position"=>12325}
]

Write chapters

Setting the chapters is just as simple:

require 'chapter'
chapters = [
    {"title"=>"Introduction", "duration"=>12325},
    {"title"=>"Discussion", "duration"=>655325}
]
Chapter.set_chapters("/path/fo/file.m4a", chapters)

CAUTION: set_chapters will overwrite any existing chapters in the file.

##Copyright

###The MIT Licence

Copyright (c) 2012 Pascal Jungblut

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.