Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created July 3, 2014 05:18
Show Gist options
  • Save ssig33/b75bb2bb892884c6d09c to your computer and use it in GitHub Desktop.
Save ssig33/b75bb2bb892884c6d09c to your computer and use it in GitHub Desktop.
#coding:utf-8
require 'fileutils'
require 'time'
require 'kconv'
AFTER_ENCODE = 'hogehoge' # エンコード後になんか実行するコマンド
SOURCE = "C:/TS" # TS とかあるところ
TARGET ="C:/MP4"
IGNORE = /BS世界の|BBC|CNN/ #音声の都合とかで HandBrake で処理したくないやつ
loop do
(Dir.glob("#{SOURCE}/*.mkv") + Dir.glob("#{SOURCE}/*.ts")).each{|ts|
next if ts =~ ITNORE
mp4 = "#{TARGET}/#{ts.split("/").last.sub(/\...$/ ,'')}.mp4"
ts = ts.gsub(/\//, "\\").tosjis
mp4 = mp4.gsub(/\//, "\\").tosjis
system "'C:/Program Files/Handbrake/HandBrakeCLI.exe' -f mp4 -Y 720 --crop 0:0:0:0 --loose-anamorphic --modulus 4 -e qsv_h264 -q 26 --cfr -a 1 -E copy --audio-fallback mp3 -x async-depth=4:gop-ref-dist=3:gop-pic-size=0:target-usage=4:mbbrc=1 --verbose=1 -i \"#{ts}\" -o \"#{mp4}\""
system AFTER_ENCODE
}
sleep 5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment