transcode 1.0.6 → 1.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f440499f81a31db9e875f0cddc6dc09287eab75d505d467385274a903ee77504
4
- data.tar.gz: 40097203d275461d347bf4f137553e34ccd0f9cb64376a0d6f6d7f488fe5aec2
3
+ metadata.gz: 31614466613fcca1314cfdba740f375f534fc2f2496e97849dfa7708eb2439f8
4
+ data.tar.gz: 062fc1cdb39ea866cfb4f16769f4f2cd0e0db7c997112b77d9eb86eaafe85efd
5
5
  SHA512:
6
- metadata.gz: 1a00be08b5cd28da92fc2314d3ce707552fbf0e55f096c139c7d7c41a95d8429e959b82cdcbebf293d40ff04fb42d255379bfd5f105bc68adefdb52094ef0aa6
7
- data.tar.gz: b8d823e3aa6c74c3deb877d001fce5e569c890dfd17b3272e0214f4b2c3609e04f6b50667e4e53727f62a4c9b98fd3f91b02e0dd5095ea8ca49d6e8573b1932d
6
+ metadata.gz: 949aa013995bfc786523ff0c13a0077b05f53e591eaccb4263708437e8f49dcc2ac754811ad5af90a52dcd951900e876ea252985772e0aeb30199874654629a8
7
+ data.tar.gz: 2f34e87bd48e5a8bc145c3016740e635da095b1a78a651ee34e597a6402e97286973e9874871ffd067a4469be9b62cc77a2d35fbaacea43e2b9a3ebbd090f068
data/README.adoc CHANGED
@@ -2,10 +2,11 @@
2
2
  :toc: macro
3
3
  :!toc-title:
4
4
  // URLs:
5
- :img-gem: https://badge.fury.io/rb/transcode.svg
5
+ :img-gem: https://img.shields.io/gem/v/transcode?color=dfaf8f&labelColor=555555&logo=rubygems&logoColor=dcdccc&style=flat
6
6
  :img-hoc: https://hitsofcode.com/github/rdavid/transcode?branch=master&label=hits%20of%20code
7
- :img-license: https://img.shields.io/github/license/rdavid/transcode?color=blue&labelColor=gray&logo=freebsd&logoColor=lightgray&style=flat
8
- :img-rake: https://github.com/rdavid/transcode/actions/workflows/rake.yml/badge.svg
7
+ :img-license: https://img.shields.io/github/license/rdavid/transcode?color=94bff3&labelColor=555555&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPHRleHQgeD0iMTIiIHk9IjIwIiBmb250LWZhbWlseT0iSGVsdmV0aWNhLEFyaWFsLHNhbnMtc2VyaWYiIGZvbnQtc2l6ZT0iMjgiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZpbGw9IiNkY2RjY2MiPiYjMTY5OzwvdGV4dD48L3N2Zz4%3D&style=flat
8
+ :img-rake: https://img.shields.io/github/actions/workflow/status/rdavid/transcode/rake.yml?branch=master&label=rake&color=7f9f7f&labelColor=555555&logo=github&logoColor=dcdccc&style=flat
9
+ :img-rubocop: https://img.shields.io/github/actions/workflow/status/rdavid/transcode/rubocop.yml?branch=master&color=8cd0d3&label=rubocop&labelColor=555555&logo=rubocop&logoColor=dcdccc&style=flat
9
10
  :url-cv: http://cv.rabkin.co.il
10
11
  :url-gem: https://badge.fury.io/rb/transcode
11
12
  :url-hoc: https://hitsofcode.com/view/github/rdavid/transcode?branch=master
@@ -13,6 +14,7 @@
13
14
  :url-melton: https://github.com/lisamelton/video_transcoding
14
15
  :url-rake: https://github.com/rdavid/transcode/actions/workflows/rake.yml
15
16
  :url-reuse: https://github.com/fsfe/reuse-action
17
+ :url-rubocop: https://github.com/rdavid/transcode/actions/workflows/rubocop.yml
16
18
  :url-requirements: https://github.com/lisamelton/video_transcoding/blob/master/README.md?ts=2#requirements
17
19
  :url-ruby: https://www.ruby-lang.org/en/documentation/installation
18
20
  :url-video: https://github.com/lisamelton/video_transcoding
@@ -21,20 +23,39 @@
21
23
 
22
24
  = Transcode
23
25
 
24
- image:{img-rake}[rake,link={url-rake}]
25
- image:{img-gem}[gem version,link={url-gem}]
26
- image:{img-hoc}[hits of code,link={url-hoc}]
27
- image:{img-license}[license,link={url-license}]
26
+ [subs=attributes+]
27
+ ++++
28
+ <div align="right">
29
+ <a href="{url-rake}"><img src="{img-rake}" alt="rake"></a>
30
+ <a href="{url-rubocop}"><img src="{img-rubocop}" alt="rubocop"></a>
31
+ <a href="{url-gem}"><img src="{img-gem}" alt="gem version"></a>
32
+ <a href="{url-hoc}"><img src="{img-hoc}" alt="hits of code"></a>
33
+ <a href="{url-license}"><img src="{img-license}" alt="license"></a>
34
+ </div>
35
+ ++++
28
36
 
29
37
  toc::[]
30
38
 
39
+ ifdef::pages-build[]
40
+ ++++
41
+ <div id="repo-link">
42
+ <a href="https://github.com/rdavid/transcode" aria-label="GitHub repository" target="_blank" rel="noopener">
43
+ <svg viewBox="0 0 16 16" width="18" height="18" fill="currentColor" aria-hidden="true">
44
+ <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/>
45
+ </svg>
46
+ </a>
47
+ </div>
48
+ ++++
49
+ endif::[]
50
+
31
51
  == About
32
52
 
33
- Transcode is a command-line tool that converts whole directories of video
34
- files in one run.
35
- It wraps {url-melton}[Lisa Melton's] {url-video}[Video Transcoding],
36
- which converts one file per invocation, and applies the same workflow
37
- to every video in a directory with a single command.
53
+ Transcode converts a whole directory of video files in one run from the
54
+ command line.
55
+ It wraps {url-melton}[Lisa Melton's] {url-video}[Video Transcoding], which
56
+ converts one file per invocation.
57
+ Transcode applies that same workflow to every video in a directory with one
58
+ command.
38
59
 
39
60
  Transcode can:
40
61
 
@@ -47,13 +68,12 @@ Transcode can:
47
68
  It recognizes these input formats: `avi`, `flv`, `m2ts`, `m4v`, `mkv`,
48
69
  `mp4`, `mpg`, `mpeg`, `mov`, `ts`, `webm`, `vob`, and `wmv`.
49
70
 
50
- == Installation
71
+ == Install
51
72
 
52
73
  Transcode ships as a Ruby gem and requires Ruby 3.2 or later.
53
74
  It runs on macOS, GNU/Linux, Windows, and any other system Ruby
54
75
  supports.
55
- See {url-ruby}[Installing Ruby] if Ruby 3.2+ is not available on your
56
- platform.
76
+ See {url-ruby}[Installing Ruby] if your platform lacks Ruby 3.2+.
57
77
 
58
78
  Install with:
59
79
 
@@ -62,7 +82,7 @@ Install with:
62
82
  gem install transcode
63
83
  ----
64
84
 
65
- == Updating
85
+ == Update
66
86
 
67
87
  Update with:
68
88
 
@@ -76,32 +96,32 @@ gem update transcode
76
96
  See Video Transcoding's {url-requirements}[requirements] for external
77
97
  dependencies.
78
98
 
79
- == Usage
99
+ == Using
80
100
 
81
101
  [,sh]
82
102
  ----
83
103
  transcode [options]
84
- -a, --act Perform actual encoding.
85
- -u, --aud aud Audio stream numbers.
86
- -d, --dir dir Source directory to transcode.
87
- -m, --mp3 Convert files to MP3.
88
- -o, --out out Output directory.
89
- -s, --sca Scan files in the directory.
90
- -t, --sub sub Subtitle stream numbers.
91
- -i, --tit tit Specific title number.
92
- -v, --version Show version.
93
- -w, --wid wid Width of the table.
104
+ -a, --act Performs actual encoding.
105
+ -u, --aud aud Sets the audio stream numbers.
106
+ -d, --dir dir Sets the directory to transcode.
107
+ -m, --mp3 Converts files to MP3.
108
+ -o, --out out Sets the output directory.
109
+ -s, --sca Scans files in the directory.
110
+ -t, --sub sub Sets the subtitle stream numbers.
111
+ -i, --tit tit Sets the title number.
112
+ -v, --version Shows the version.
113
+ -w, --wid wid Sets the output table width.
94
114
  ----
95
115
 
96
116
  Transcode performs a dry run by default.
97
117
  It prints the commands it would run and a summary table without changing any
98
118
  files.
99
- Pass `--act` to start the encoding.
119
+ Adding `--act` starts the encoding.
100
120
 
101
121
  Without `--dir` and `--out`, Transcode reads from and writes to the current
102
122
  directory.
103
- The `--aud` and `--sub` options take comma-separated stream numbers, either
104
- one value applied to every file or one value per file.
123
+ The `--aud` and `--sub` options take comma-separated stream numbers: one
124
+ value applies to every file, or each file takes its own value.
105
125
 
106
126
  == Examples
107
127
 
@@ -136,5 +156,22 @@ transcode --mp3 --act
136
156
 
137
157
  == License
138
158
 
139
- `transcode` is copyright {url-cv}[David Rabkin] and available under a
159
+ `transcode` carries copyright by {url-cv}[David Rabkin] and ships under a
140
160
  {url-license}[Zero-Clause BSD license].
161
+
162
+ ifdef::pages-build[]
163
+ ++++
164
+ <footer id="site-footer">
165
+ <div class="footer-left">
166
+ <img src="favicon.svg" alt="" width="20" height="20">
167
+ <span>transcode by <a href="http://cv.rabkin.co.il" target="_blank" rel="noopener">David Rabkin</a></span>
168
+ </div>
169
+ <div class="footer-links">
170
+ <a href="https://github.com/rdavid/transcode" target="_blank" rel="noopener">GitHub</a>
171
+ <a href="https://badge.fury.io/rb/transcode" target="_blank" rel="noopener">RubyGems</a>
172
+ <a href="https://github.com/rdavid/transcode/releases" target="_blank" rel="noopener">Releases</a>
173
+ <a href="https://github.com/rdavid/transcode/blob/master/LICENSES/0BSD.txt" target="_blank" rel="noopener">0BSD License</a>
174
+ </div>
175
+ </footer>
176
+ ++++
177
+ endif::[]
@@ -13,22 +13,22 @@ module Transcode
13
13
  attr_reader :files
14
14
 
15
15
  DIC = [
16
- ['-a', '--act', 'Perform actual encoding.', nil, :act],
17
- ['-u', '--aud aud', 'Audio stream numbers.', Array, :aud],
18
- ['-d', '--dir dir', 'Source directory to transcode.', String, :dir],
19
- ['-m', '--mp3', 'Convert files to MP3.', nil, :mp3],
20
- ['-o', '--out out', 'Output directory.', String, :out],
21
- ['-s', '--sca', 'Scan files in the directory.', nil, :sca],
22
- ['-t', '--sub sub', 'Subtitle stream numbers.', Array, :sub],
23
- ['-i', '--tit tit', 'Specific title number.', Array, :tit],
24
- ['-w', '--wid wid', 'Width of the table.', Integer, :wid]
16
+ ['-a', '--act', 'Performs actual encoding.', nil, :act],
17
+ ['-u', '--aud aud', 'Sets the audio stream numbers.', Array, :aud],
18
+ ['-d', '--dir dir', 'Sets the directory to transcode.', String, :dir],
19
+ ['-m', '--mp3', 'Converts files to MP3.', nil, :mp3],
20
+ ['-o', '--out out', 'Sets the output directory.', String, :out],
21
+ ['-s', '--sca', 'Scans files in the directory.', nil, :sca],
22
+ ['-t', '--sub sub', 'Sets the subtitle stream numbers.', Array, :sub],
23
+ ['-i', '--tit tit', 'Sets the title number.', Array, :tit],
24
+ ['-w', '--wid wid', 'Sets the output table width.', Integer, :wid]
25
25
  ].freeze
26
26
  EXT = %w[
27
27
  avi flv m2ts m4v mkv mp4 mpg mpeg mov ts webm vob wmv
28
28
  ].join(',').freeze
29
29
 
30
30
  def add(opt)
31
- opt.on('-v', '--version', 'Show version.') do
31
+ opt.on('-v', '--version', 'Shows the version.') do
32
32
  puts "#{File.basename($PROGRAM_NAME)} #{VERSION} #{DATE}"
33
33
  exit
34
34
  end
@@ -40,9 +40,10 @@ module Transcode
40
40
  c + " #{file.shellescape}"
41
41
  end
42
42
 
43
- # Converts file, audio, subtitle, and title arrays into an array:
44
- # [ file1 [ aud1, sub1, tit1 ] ]
45
- # [ file2 [ aud2, sub2, tit2 ] ]
43
+ # Converts file, audio, subtitle, and title arrays into an array of
44
+ # pairs:
45
+ # [ file1, [ aud1, sub1, tit1 ] ]
46
+ # [ file2, [ aud2, sub2, tit2 ] ]
46
47
  def data
47
48
  @data ||= @cfg.files.zip([@cfg.aud, @cfg.sub, @cfg.tit].transpose)
48
49
  end
@@ -54,10 +55,28 @@ module Transcode
54
55
  end
55
56
  end
56
57
 
58
+ def mp3_dst(file)
59
+ "#{@cfg.out}/#{File.basename(file, '.*')}.mp3"
60
+ end
61
+
62
+ # Skips files whose destination MP3 already exists, so reruns only
63
+ # convert what's missing.
64
+ def mp3_files
65
+ @cfg.files.reject do |f|
66
+ dst = mp3_dst(f)
67
+ File.exist?(dst).tap { |exists| warn "Skip: #{f} exists as #{dst}." if exists }
68
+ end
69
+ end
70
+
71
+ # -q:a 0 requests libmp3lame's highest VBR quality (V0), letting
72
+ # bitrate adapt to content complexity instead of spending a fixed
73
+ # rate on simple passages. No -ar is given, so ffmpeg keeps the
74
+ # source's sample rate when libmp3lame supports it directly (44100,
75
+ # 48000, 32000, and others), instead of downsampling every file,
76
+ # most commonly 48kHz video audio, to 44100.
57
77
  def mp3_cmd(file)
58
- file = file.shellescape
59
- "ffmpeg -i #{file} -vn -ar 44100 -ac 2 -ab 192k -f mp3 " \
60
- "#{@cfg.out}/#{File.basename(file, '.*')}.mp3"
78
+ "ffmpeg -nostdin -i #{file.shellescape} -ac 2 -f mp3 -q:a 0 -vn " \
79
+ "#{mp3_dst(file)}"
61
80
  end
62
81
 
63
82
  def scn_cmd(file)
@@ -66,7 +85,7 @@ module Transcode
66
85
 
67
86
  def do
68
87
  if @cfg.mp3?
69
- @cfg.files.each { |f| @rep.add(f, @cfg.act? ? run(mp3_cmd(f)) : true) }
88
+ mp3_files.each { |f| @rep.add(f, @cfg.act? ? run(mp3_cmd(f)) : true) }
70
89
  elsif @cfg.sca?
71
90
  @cfg.files.each { |f| @rep.add(f, run(scn_cmd(f))) }
72
91
  else
@@ -5,6 +5,6 @@
5
5
  # SPDX-License-Identifier: 0BSD
6
6
 
7
7
  module Transcode
8
- VERSION = '1.0.6'
9
- DATE = '2026-07-15'
8
+ VERSION = '1.0.7'
9
+ DATE = '2026-09-13'
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rabkin