ffiosconvert 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/bin/ffiosconvert +19 -0
  2. data/lib/converter.rb +52 -0
  3. metadata +49 -0
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "converter"
4
+
5
+ begin
6
+ raise "Too many arguments" if ARGV.size > 1
7
+ res = ARGV.empty? ? "640x360" : ARGV[0]
8
+ Converter.new(res)
9
+
10
+ rescue StandardError=>error
11
+ puts "#{error}\n\n" unless error.nil?
12
+ puts "Usage:\nffiosconvert <WIDTHxHEIGHT>"
13
+ puts "\t- default value is 640x360"
14
+ puts "\t- example: ffiosconvert 320x180"
15
+ puts ""
16
+ exit 1
17
+ end
18
+
19
+ exit 0
@@ -0,0 +1,52 @@
1
+ VIDEO_EXT = %w{3gp asf avi flv mkv mov qt swf vob wmv}.freeze
2
+
3
+ class Converter
4
+ @dir = nil
5
+ @res = nil
6
+
7
+ public
8
+
9
+ def initialize(res)
10
+ @res = res
11
+ convert_dir
12
+ end
13
+
14
+ private
15
+
16
+ def convert_dir
17
+ @dir = "Converted_#{@res}"
18
+ Dir.mkdir(@dir) unless Dir.exists?(@dir)
19
+ original_list.each do |e|
20
+ command = convert_file(e)
21
+ puts "command = #{command}"
22
+ if !command.nil?
23
+ puts "--- Converting #{e} ---"
24
+ success = system(convert_file(e))
25
+ raise "Failed on \"#{e}\" conversion" unless success
26
+ puts "=== Finished #{e} ==="
27
+ end
28
+ end
29
+ end
30
+
31
+ def convert_file(file)
32
+ name = "#{@dir}/#{file[0...-File.extname(file).size]}.mp4"
33
+ if File.exists?(name)
34
+ puts "\nSkipped. File '#{name}' is already exists\n"
35
+ else
36
+ "ffmpeg -i \"#{file}\" -acodec libfaac -vcodec mpeg4 -b 1200k -s #{@res} \"#{name}\""
37
+ end
38
+ end
39
+
40
+ def original_list
41
+ entries = Dir.entries(Dir.pwd)
42
+ entries = entries.find_all do |e|
43
+ if File.file?(e)
44
+ ext = File.extname(e).downcase[1..-1]
45
+ VIDEO_EXT.include?(ext)
46
+ end
47
+ end
48
+ raise "No video files in \"#{Dir.pwd}\"" if entries.empty?
49
+ entries
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffiosconvert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexey Belkevich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: FFMpeg based script for video conversion to iOS devices (iPad, iPad mini,
15
+ iPhone5, iPhone/iPod retina, iPhone/iPod) format
16
+ email: belkevich@okolodev.org
17
+ executables:
18
+ - ffiosconvert
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/converter.rb
23
+ - bin/ffiosconvert
24
+ homepage: https://github.com/belkevich/ffiosconvert
25
+ licenses:
26
+ - MIT
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 1.8.23
46
+ signing_key:
47
+ specification_version: 3
48
+ summary: FFMpeg based script for video conversion to iOS devices format
49
+ test_files: []