Skip to content

Commit

Permalink
Merge 0253929 into d6f371a
Browse files Browse the repository at this point in the history
  • Loading branch information
little9 committed Mar 31, 2017
2 parents d6f371a + 0253929 commit a4802ca
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/hydra/derivatives.rb
Expand Up @@ -33,6 +33,7 @@ module Derivatives
autoload :PersistBasicContainedOutputFileService
autoload :TempfileService
autoload :MimeTypeService
autoload :CapabilityService
end

# Raised if the timout elapses
Expand Down
10 changes: 9 additions & 1 deletion lib/hydra/derivatives/processors/video/config.rb
Expand Up @@ -19,7 +19,15 @@ def audio_attributes
end

def mpeg4
@mpeg4 ||= CodecConfig.new('-vcodec libx264 -acodec libfdk_aac')
@mpeg4 ||=
@audio_encoder_capability = Hydra::Derivatives::CapabilityService.new
@audio_encoder_capability.capture_output
audio_encoder = if @audio_encoder_capability.fdk_aac?
'libfdk_aac'
else
'aac'
end
CodecConfig.new("-vcodec libx264 -acodec #{audio_encoder}")
end

def webm
Expand Down
14 changes: 14 additions & 0 deletions lib/hydra/derivatives/services/capability_service.rb
@@ -0,0 +1,14 @@
require 'open3'

module Hydra::Derivatives
class CapabilityService
attr_accessor :ffmpeg_output
def capture_output
@ffmpeg_output = Open3.capture3('ffmpeg -codecs').to_s
end

def fdk_aac?
@ffmpeg_output.include?('--enable-libfdk-aac') || @ffmpeg_output.include?('--with-fdk-aac')
end
end
end
19 changes: 19 additions & 0 deletions spec/services/capability_service_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'

describe Hydra::Derivatives::CapabilityService do
before do
@aac_capability = described_class.new
end
describe 'fdk_aac?' do
it 'tells you if fdk_aac encoder is installed' do
@aac_capability.ffmpeg_output = 'ffmpeg version 2.2.2 Copyright (c) 2000-2014 the FFmpeg developers
built on May 14 2014 11:52:48 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libvpx --enable-libfdk-aac'
expect(@aac_capability.fdk_aac?).to eq(true)
end
it 'tells you if fdk_aac encoder is not installed' do
@aac_capability.ffmpeg_output = "ffmpeg version 3.1.7 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20161221 (Red Hat 6.3.1-1) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enabl e-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect"
expect(@aac_capability.fdk_aac?).to eq(false)
end
end
end

0 comments on commit a4802ca

Please sign in to comment.