Skip to content

Instantly share code, notes, and snippets.

@kumabook
Last active September 3, 2018 02:12
Show Gist options
  • Save kumabook/7357346 to your computer and use it in GitHub Desktop.
Save kumabook/7357346 to your computer and use it in GitHub Desktop.
HandBrakeCLIを使って、DVDをチャプターごとにmp4に変換するスクリプトです。gem handbrakeおよびHandBrakeCLIが必要です。
#!/usr/bin/ruby
require 'rubygems'
require 'handbrake'
VOLUME = '/Volumes/Untitled UDF Volume/'
DIST_DIR = '.'
PREFIX = 'antonio-'
HAND_BRAKE_CLI = '/usr/local/Cellar/handbrake/1.1.1/bin/HandBrakeCLI'
hb = HandBrake::CLI.new(:bin_path => HAND_BRAKE_CLI, :trace => false)
project = hb.input(VOLUME)
disc = project.scan
title = disc.titles[1]
size = title.chapters.size
(1..size).each do |i|
chap = title.chapters[i]
unless chap.nil?
puts 'start chapter-' + chap.number.to_s
project.title(1).preset('High Profile').chapter(chap.number.to_s + '-' + chap.number.to_s).output(DIST_DIR + '/' + PREFIX + chap.number.to_s + '.mp4')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment