Last active
September 3, 2018 02:12
-
-
Save kumabook/7357346 to your computer and use it in GitHub Desktop.
HandBrakeCLIを使って、DVDをチャプターごとにmp4に変換するスクリプトです。gem handbrakeおよびHandBrakeCLIが必要です。
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
#!/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