-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial public release of FFMPEG cookbook
- Loading branch information
Jamie Winsor
committed
Jul 7, 2011
0 parents
commit b7c409e
Showing
8 changed files
with
351 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
DESCRIPTION | ||
=========== | ||
|
||
Installs FFMPEG, a complete, cross-platform solution to record, convert and stream audio and video - [FFMPEG](http://www.ffmpeg.org/) | ||
|
||
Requirements | ||
============ | ||
|
||
* Chef 0.10 | ||
* Ubuntu 10.04 | ||
|
||
Please help increase the supported platform list by notifying me of coincidental support or by submitting a pull request which will add support for an additional platform(s). | ||
|
||
Attributes | ||
========== | ||
|
||
* +ffmpeg[:install_method]+ - Installation method, `:source` or `:package` - default `:source` | ||
* +ffmpeg[:prefix]+ - Location prefix of where the installation files will go if installing via `:source` | ||
* +ffmpeg[:git_repository]+ - Location of the source Git repository if installing via `:source` | ||
* +ffmpeg[:git_revision]+ - Revision of the Git repository to install if installing via `:source`. Points to version 0.6.3 by default | ||
* +ffmpeg[:compile_flags]+ - Array of flags to use in compilation process if installing via `:source`. FFMPEG will be recompiled if this attribute is modified after initial compilation | ||
* +ffmpeg[:libvpx][:revision]+ - Overrides the revision specified in the libvpx cookbook for the version of libvpx to configure and install if installing via `:source` | ||
* +ffmpeg[:x264][:revision]+ - Overrides the revision specified in the x264 cookbook for the version of x264 to configure and install if installing via `:source` | ||
|
||
WARN: When specifying the `git_revision` attribute, use the hash of commit or a HEAD - not a tag. Sync action of Git provider will always attempt to update the git clone if a tag is used. | ||
|
||
Development | ||
=========== | ||
|
||
* Source hosted at [GitHub](https://github.com/enmasse-entertainment/ffmpeg-cookbook) | ||
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/enmasse-entertainment/ffmpeg-cookbook/issues) | ||
|
||
Pull requests are very welcome! Make sure your patches are well tested. | ||
Ideally create a topic branch for every separate change you make. | ||
|
||
LICENSE and AUTHOR | ||
================== | ||
|
||
Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
|
||
Copyright:: 2011, En Masse Entertainment, Inc | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# Cookbook Name:: ffmpeg | ||
# Attributes:: default | ||
# | ||
# Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
# | ||
# Copyright 2011, En Masse Entertainment, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
default[:ffmpeg][:install_method] = :source | ||
default[:ffmpeg][:prefix] = "/usr/local" | ||
default[:ffmpeg][:git_repository] = "git://git.videolan.org/ffmpeg.git" | ||
default[:ffmpeg][:compile_flags] = [ | ||
"--disable-debug", | ||
"--enable-pthreads", | ||
"--enable-nonfree", | ||
"--enable-gpl", | ||
"--disable-indev=jack", | ||
"--enable-libx264", | ||
"--enable-libfaac", | ||
"--enable-libmp3lame", | ||
"--enable-libtheora", | ||
"--enable-libvorbis", | ||
"--enable-libvpx", | ||
"--enable-libxvid", | ||
"--enable-libfaad" | ||
] | ||
|
||
# JW 07-06-11: Hash of commit or a HEAD should be used - not a tag. Sync action of Git | ||
# provider will always attempt to update the git clone if a tag is used. | ||
default[:ffmpeg][:git_revision] = "ace432f62cdcedf812e7c4d77fc5b03322170fa8" # 0.6.3 | ||
|
||
default[:ffmpeg][:libvpx][:revision] = "0491c2cfc89cded04de386ae691654c7653aac9b" | ||
default[:ffmpeg][:x264][:revision] = "stable" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# | ||
# Cookbook Name:: ffmpeg | ||
# Library:: helpers | ||
# | ||
# Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
# | ||
# Copyright 2011, En Masse Entertainment, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
module FFMPEG | ||
module Helpers | ||
# Returns an array of strings representing the names of packages that are the | ||
# prerequisites of the given array of compilation flags for FFMPEG. Package | ||
# names returned are determined by the platform running this recipe. | ||
def find_prerequisite_packages_by_flags(compile_flags) | ||
packages = [] | ||
compile_flags.each do |flag| | ||
packages = packages | packages_for_flag(flag) | ||
end | ||
|
||
packages | ||
end | ||
|
||
# Returns an array of package names that will install FFMPEG on a node. | ||
# Package names returned are determined by the platform running this recipe. | ||
def ffmpeg_packages | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "ffmpeg" ] }, | ||
"default" => [ "ffmpeg" ] | ||
) | ||
end | ||
|
||
private | ||
|
||
def packages_for_flag(flag) | ||
case flag | ||
when "--enable-libfaac" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libfaac-dev" ] }, | ||
"default" => [ "libfaac-dev" ] | ||
) | ||
when "--enable-libmp3lame" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libmp3lame-dev" ] }, | ||
"default" => [ "libmp3lame-dev" ] | ||
) | ||
when "--enable-libtheora" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libtheora-dev" ] }, | ||
"default" => [ "libtheora-dev" ] | ||
) | ||
when "--enable-libvorbis" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libvorbis-dev" ] }, | ||
"default" => [ "libvorbis-dev" ] | ||
) | ||
when "--enable-libxvid" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libxvidcore-dev" ] }, | ||
"default" => [ "libxvidcore-dev" ] | ||
) | ||
when "--enable-libfaad" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libfaad-dev" ] }, | ||
"default" => [ "libfaad-dev" ] | ||
) | ||
when "--enable-libvpx" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libvpx-dev" ] }, | ||
"default" => [ "libvpx-dev" ] | ||
) | ||
when "--enable-libx264" | ||
value_for_platform( | ||
[ "ubuntu" ] => { "default" => [ "libx264-dev" ] }, | ||
"default" => [ "libx264-dev" ] | ||
) | ||
else | ||
[] | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Chef::Recipe | ||
include FFMPEG::Helpers | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
maintainer "En Masse Entertainment" | ||
maintainer_email "jamie@enmasse.com" | ||
license "Apache 2.0" | ||
description "Installs and configures FFMPEG from source or package" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.1.0" | ||
|
||
supports "ubuntu", "10.04" | ||
|
||
depends "x264", "~> 0.1.1" | ||
depends "libvpx", "~> 0.1.1" | ||
depends "build-essential" | ||
depends "git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Cookbook Name:: ffmpeg | ||
# Recipe:: default | ||
# | ||
# Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
# | ||
# Copyright 2011, En Masse Entertainment, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
case node[:ffmpeg][:install_method] | ||
when :source | ||
include_recipe "ffmpeg::source" | ||
when :package | ||
include_recipe "ffmpeg::package" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Cookbook Name:: ffmpeg | ||
# Recipe:: package | ||
# | ||
# Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
# | ||
# Copyright 2011, En Masse Entertainment, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
ffmpeg_packages.each do |pkg| | ||
package pkg do | ||
action :upgrade | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# | ||
# Cookbook Name:: ffmpeg | ||
# Recipe:: source | ||
# | ||
# Author:: Jamie Winsor (<jamie@enmasse.com>) | ||
# | ||
# Copyright 2011, En Masse Entertainment, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
include_recipe "build-essential" | ||
include_recipe "git" | ||
|
||
ffmpeg_packages.each do |pkg| | ||
package pkg do | ||
action :purge | ||
end | ||
end | ||
|
||
node.override[:x264][:git_revision] = node[:ffmpeg][:x264][:revision] | ||
include_recipe "x264::source" | ||
node.override[:libvpx][:git_revision] = node[:ffmpeg][:libvpx][:revision] | ||
include_recipe "libvpx::source" | ||
|
||
yasm_package = value_for_platform( | ||
[ "ubuntu" ] => { "default" => "yasm" }, | ||
"default" => "yasm" | ||
) | ||
|
||
package yasm_package do | ||
action :upgrade | ||
end | ||
|
||
# Filter the packages that we just built from source via their compile flag | ||
flags_for_upgrade = node[:ffmpeg][:compile_flags].reject do |flag| | ||
["--enable-libx264", "--enable-libvpx"].include?(flag) | ||
end | ||
|
||
find_prerequisite_packages_by_flags(flags_for_upgrade).each do |pkg| | ||
package pkg do | ||
action :upgrade | ||
end | ||
end | ||
|
||
git "#{Chef::Config[:file_cache_path]}/ffmpeg" do | ||
repository node[:ffmpeg][:git_repository] | ||
reference node[:ffmpeg][:git_revision] | ||
action :sync | ||
notifies :run, "bash[compile_ffmpeg]" | ||
end | ||
|
||
# Write the flags used to compile the application to Disk. If the flags | ||
# do not match those that are in the compiled_flags attribute - we recompile | ||
template "#{Chef::Config[:file_cache_path]}/ffmpeg-compiled_with_flags" do | ||
source "compiled_with_flags.erb" | ||
owner "root" | ||
group "root" | ||
mode 0600 | ||
variables( | ||
:compile_flags => node[:ffmpeg][:compile_flags] | ||
) | ||
notifies :run, "bash[compile_ffmpeg]", :immediately | ||
end | ||
|
||
bash "compile_ffmpeg" do | ||
cwd "#{Chef::Config[:file_cache_path]}/ffmpeg" | ||
code <<-EOH | ||
./configure --prefix=#{node[:ffmpeg][:prefix]} #{node[:ffmpeg][:compile_flags].join(' ')} | ||
make clean && make && make install | ||
EOH | ||
action :nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Generated automatically by Chef | ||
# Removing or modifying this file will cause FFMPEG to recompile during the next Chef run. | ||
<% @compile_flags.each do |flag| %> | ||
<%= flag %> | ||
<% end %> |