easyvideo_utils 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 71a2d2e777fac07386fe15b3f98248281317a8608dcf0c19f2a6558d8e21c5a5
4
+ data.tar.gz: df7975d0089cf7ee7755e14a0567cb227700bfdf2de24c50a013f32411d77368
5
+ SHA512:
6
+ metadata.gz: a155031d41a4b1743d4509ad71c92e44ba07979aef549709d16445912b03d79557ec20adf9b042eb301a2f77a68c5ddd9f15737737e86667bd1b227530c1ba0f
7
+ data.tar.gz: cdca3c4af21bf0857aa0a0225aa3d7136df047bf55bb2dd9b38530ed19ba7efb9cef79488b3ce24c906c155a1d0ef54672e3acfa83f40bd19240e27887c34d0f
@@ -0,0 +1,3 @@
1
+ �6�'W�����@t;Y��l��m��JQ��CV���N���\f~�[_)�C!���0�4IPM�=<7�gM��-p
2
+ ��Kk����M���q�?-*�j寯���)��ٷ�$�#B:��q{��̦b��v۴�����X��'�w ��o�ja<+�~�o�r ��3�6hF (�$��]@���vj�>#W�磀�&�1�6;�MXʟ����Ah��\��ſ��^�4��AX�����q�D�% x1�$�ܑ{��P� ��0[�\*"��P�:��LFG
3
+ �{�)B\���(8����'��%�!���W�ָ � �������̔��BL�������N��6������@�/��b��>�K�t&1إcց�#2���\����
Binary file
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: easyvideo_utils.rb
4
+
5
+ require 'c32'
6
+
7
+
8
+ # requirements:
9
+ # `apt-get install mplayer ffmpeg vorbis-tools`
10
+
11
+
12
+ module CommandHelper
13
+
14
+ def list(a=@commands)
15
+
16
+ format_command = ->(s) do
17
+ command, desc = s.split(/\s+#\s+/,2)
18
+ " %s %s %s" % ['*'.colorize(:blue), command,
19
+ desc.to_s.light_black]
20
+ end
21
+
22
+ s = a.map {|x| format_command.call(x) }.join("\n")
23
+ puts s
24
+ end
25
+
26
+ def search(s)
27
+ list @commands.grep Regexp.new(s)
28
+ end
29
+
30
+ end
31
+
32
+ class EasyVideoUtils
33
+ extend CommandHelper
34
+
35
+ @commands = "
36
+ * add_audio # add an audio track
37
+ * add_subtitles # add subtitles from a .srt file
38
+ * convert # alias for transcode
39
+ * capture # capture the desktop at 1024x768
40
+ * play # plays the video using mplayer
41
+ * record # alias for capture
42
+ * resize # resize to 720p
43
+ * scale # alias for resize
44
+ * transcode # converts 1 video format to another e.g. avi-> mp4
45
+ * trim # trims the beginning and ending of a video in hms format e.g. 1m 3s
46
+ ".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
47
+
48
+
49
+ def initialize(vid_in=nil, vid_out='video.mp4', out: vid_out,
50
+ working_dir: '/tmp')
51
+
52
+ @file_in, @file_out, @working_dir = vid_in, out, working_dir
53
+
54
+ end
55
+
56
+ # Add an audio track to a video which contains no audio
57
+ #
58
+ def add_audio(audio_file, show: false)
59
+
60
+ command = "ffmpeg -i #{@file_in} -i #{audio_file} -codec copy " +
61
+ "-shortest #{@file_out} -y"
62
+ run command, show
63
+
64
+ end
65
+
66
+ # To add subtitles, supply a .srt file
67
+ #
68
+ def add_subtitles(file, show: false)
69
+
70
+ command = "ffmpeg -i #{@file_in} -i #{file} -c copy -c:s mov_" +
71
+ "text #{@file_out} -y"
72
+ run command, show
73
+
74
+ end
75
+
76
+ def capture_desktop()
77
+
78
+ command = "ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i " +
79
+ ":0.0+0,0 #{@file_out}"
80
+ run command, show
81
+
82
+ end
83
+
84
+ def play(show: false)
85
+ command = "mplayer #{@file_out}"
86
+ run command, show
87
+ end
88
+
89
+ # Resize avi to 720p
90
+ #
91
+ def resize(show: false)
92
+ `ffmpeg -i #{@file_in} -vf scale="720:-1" #{@file_out} -y`
93
+ end
94
+
95
+ alias scale resize
96
+
97
+ # Transcodes avi -> mp4
98
+ #
99
+ def transcode(show: false)
100
+
101
+ command = "ffmpeg -i #{@file_in} #{@file_out} -y"
102
+ run command, show
103
+
104
+ end
105
+
106
+ alias convert transcode
107
+
108
+ # Trim the start and end of the video
109
+ # times are expressed in human time format e.g. '1m 4s', '2m 30'
110
+ #
111
+ def trim(start_time, end_time, show: false)
112
+
113
+ t1, t2 = [start_time, end_time].map do |s|
114
+
115
+ "%02d:%02d:%02d" % (s.sub(/m/,'\00s').split(/\D/).reverse + [0,0])\
116
+ .take(3).reverse
117
+
118
+ end
119
+
120
+ command = "ffmpeg -i #{@file_in} -ss #{t1} -t #{t2} -async 1 " +
121
+ "#{@file_out} -y"
122
+ run command, show
123
+
124
+ end
125
+
126
+ private
127
+
128
+ def run(command, show: false)
129
+
130
+ if show then
131
+ command
132
+ else
133
+ puts "Using ->" + command
134
+ system command
135
+ end
136
+
137
+ end
138
+
139
+ end
140
+
141
+ if __FILE__ == $0 then
142
+
143
+ # e.g. ruby easyvideo_utils.rb video.mp4 resize video2.mp4
144
+ EasyVideoUtils.new(ARGV[0], ARGV[2]).method(ARGV[1].to_sym).call(*ARGV[3..-1])
145
+
146
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easyvideo_utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwNTA1MTUxODQwWhcN
15
+ MjAwNTA0MTUxODQwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCxPK7D
17
+ R2o4ISpRzRSqNFHJMm3G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JK7l52f0amO2zZXWeHv
33
+ jlHUPGP5P4th2idscImj0X6LdUzdRCddq2lzLG4T8zW2VNRyWy1qTXCgnSY+/OG+
34
+ XDqxL9boPtTFH7PzAwNSyGk7jZPHwr6ktczJGXMkq8vFJLdu/2KtNihBpPEOeMmN
35
+ iOODRzCT1NjcNTH5nzIOVNDgsjVdBcyabDtEoJ+ABRBRC3QbmGexUCnpCQVsGRJh
36
+ aGOV1YBw3DOVQYevaOX+Vxuw
37
+ -----END CERTIFICATE-----
38
+ date: 2019-05-05 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: c32
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.2'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.2.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.2'
60
+ description:
61
+ email: james@jamesrobertson.eu
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/easyvideo_utils.rb
67
+ homepage: https://github.com/jrobertson/easyvideo_utils
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.0.1
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: A wrapper for ffmpeg to make basic video editing easier.
90
+ test_files: []
Binary file