other_video_transcoding 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1982b8ee6d952b01d5c36833c741754ccd37508c0edc34a6b1de1b61daf9a21
4
- data.tar.gz: 82d4874af0e4b9d25487a9f49764f920750c18dc7c368d0b8fd06fb35bef5c97
3
+ metadata.gz: fbe4654304564db44ba76d5b6b4a805a853e4ae2fca1238f69d7ceac6152970b
4
+ data.tar.gz: 5104621d3963ddacfd90796a2dd9cad57fc04f03c47e6122cc7dccd3794df16c
5
5
  SHA512:
6
- metadata.gz: aa06c1a7c65f63ff2b3e3ce93d25a9b50588cb7d938b1990100236b973fe832e367ae54fa8cd5d44a582d3e14e050d68ed2f9a5d14a1c4381c1314c4ddd07b5a
7
- data.tar.gz: 948c96268b59b5f09dba5314ceea8cbe9a47cbbe7a196128d2d266b2d7949c2a5620aa71eae759ffedd90a1c35bacf934fcfa8d585c04718d957d61418c0cf3b
6
+ metadata.gz: 6eec714eb59091c7ee48b74a4ac6dba65b3333bfa3dbb76b24ef5afb334e0c7434cc16234fe8e056cb7328eecc820794a8f54433082a49db6e06c02b812c690d
7
+ data.tar.gz: ff5ee96313996a08b9433e223c64e01b492c7bebc1735c5533d6f263373c56e8202d13e78bd9c07221f6b08c502577d9ae8701a53f5741a4ce57911b8024b826
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This single document contains all of the notes created for each [release](https://github.com/donmelton/other_video_transcoding/releases).
4
4
 
5
+ ## [0.2.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.2.0)
6
+
7
+ Monday, January 13, 2020
8
+
9
+ * Allow `all` to be used as an argument to the `--add-audio` and `--add-subtitle` options of `other-transcode`, adding all audio tracks or all subtitle tracks. Via [ #3](https://github.com/donmelton/other_video_transcoding/issues/3).
10
+ * Add `original` as a width attribute to the `--main-audio` and `--add-audio` options of `other-transcode`. Unlike `stereo` and `surround`, this disables transcoding and always copies the selected track(s). Via [ #5](https://github.com/donmelton/other_video_transcoding/issues/5).
11
+ * Add a `--copy-video` option to `other-transcode`. This disables transcoding and copies the original video track to the output.
12
+ * No longer ignore any image-based subtitles added to MP4 output. Instead, let `ffmpeg` foolishly add DVD-style subtitles and (currently) fail when adding Blu-ray Disc-style subtitles.
13
+ * Deprecate the `--name` option of `other-transcode` because it doesn't make sense to name only the first output file from a tool which can take multiple inputs. The option still works for now, but using it issues a warning message. It will be removed in a future release.
14
+ * Remove warnings when other options disable the Nvidia video decoder, which could only happen if the `--burn-subtitle` or `--detelecine` options were used with the `--cuvid` option.
15
+
5
16
  ## [0.1.1](https://github.com/donmelton/other_video_transcoding/releases/tag/0.1.1)
6
17
 
7
18
  Friday, January 3, 2020
data/bin/ask-ffmpeg-log CHANGED
@@ -16,7 +16,7 @@ module Transcoding
16
16
  class Command
17
17
  def about
18
18
  <<HERE
19
- ask-ffmpeg-log 0.1.1
19
+ ask-ffmpeg-log 0.2.0
20
20
  Copyright (c) 2019-2020 Don Melton
21
21
  HERE
22
22
  end
data/bin/other-transcode CHANGED
@@ -18,7 +18,7 @@ module Transcoding
18
18
  class Command
19
19
  def about
20
20
  <<HERE
21
- other-transcode 0.1.1
21
+ other-transcode 0.2.0
22
22
  Copyright (c) 2019-2020 Don Melton
23
23
  HERE
24
24
  end
@@ -59,8 +59,6 @@ HERE
59
59
  <<HERE
60
60
  --print-crop print only detected video crop geometry and exit
61
61
  --mp4 output MP4 instead of Matroska `.mkv` format
62
- --name STRING set output filename, excluding format extension
63
- (default: based on input filename)
64
62
  --copy-track-names
65
63
  copy all input audio track names to output
66
64
  HERE
@@ -132,6 +130,7 @@ HERE
132
130
 
133
131
  def usage10
134
132
  <<HERE
133
+ --copy-video disable transcoding and copy original video track
135
134
 
136
135
  Apple Video Toolbox encoder options:
137
136
  --vt-allow-sw allow software encoding
@@ -185,9 +184,22 @@ Audio options:
185
184
  --main-audio TRACK[=WIDTH]
186
185
  select main audio track by number (default: 1)
187
186
  with optional width (default: surround)
188
- --add-audio TRACK|LANGUAGE|STRING[=WIDTH]
187
+ HERE
188
+ end
189
+
190
+ def usage12
191
+ <<HERE
192
+ (use `original` to disable transcoding)
193
+ HERE
194
+ end
195
+
196
+ def usage13
197
+ <<HERE
198
+ --add-audio TRACK|all|LANGUAGE|STRING[=WIDTH]
189
199
  add single audio track by number
190
200
  including main audio track
201
+ or all audio tracks
202
+ excluding main audio track
191
203
  or audio tracks by language code
192
204
  excluding main audio track
193
205
  (in ISO 639-2 format, e.g.: `eng`)
@@ -195,6 +207,17 @@ Audio options:
195
207
  excluding main audio track
196
208
  (comparison is case-insensitve)
197
209
  with optional width (default: stereo)
210
+ HERE
211
+ end
212
+
213
+ def usage14
214
+ <<HERE
215
+ (use `original` to disable transcoding)
216
+ HERE
217
+ end
218
+
219
+ def usage15
220
+ <<HERE
198
221
  --surround-bitrate BITRATE
199
222
  set surround audio bitrate (default: 640)
200
223
  --stereo-bitrate BITRATE
@@ -202,15 +225,16 @@ Audio options:
202
225
  --eac3 use Enhanced AC-3 format for surround audio
203
226
 
204
227
  Subtitle options:
205
- --add-subtitle TRACK[=forced]|auto|LANGUAGE|STRING
228
+ --add-subtitle TRACK[=forced]|auto|all|LANGUAGE|STRING
206
229
  add single subtitle track by number
207
230
  optionally setting forced disposition
208
231
  or enable automatic addition of forced subtitle
209
- or add subtitle tracks by language code
232
+ or add all subtitle tracks
233
+ or subtitle tracks by language code
210
234
  (in ISO 639-2 format, e.g.: `eng`)
211
235
  or subtitle tracks with titles containing string
212
236
  (comparison is case-insensitve)
213
- (all variations exclude any burned track)
237
+ (variations exclude any burned track)
214
238
  --burn-subtitle TRACK|auto
215
239
  burn subtitle track by number into video
216
240
  or enable automatic burning of forced subtitle
@@ -295,12 +319,13 @@ HERE
295
319
  case arg
296
320
  when 'full'
297
321
  puts usage1 + usage2 + usage3 + usage4 + usage5 + usage6 +
298
- usage7 + usage8 + usage9 + usage10 + usage11
322
+ usage7 + usage8 + usage9 + usage10 + usage11 + usage12 +
323
+ usage13 + usage14 + usage15
299
324
  when 'more'
300
325
  puts usage1 + usage2 + usage3 + usage4 + usage6 + usage7 +
301
- usage8 + usage9 + usage11
326
+ usage8 + usage9 + usage11 + usage13 + usage15
302
327
  else
303
- puts usage1 + usage3 + usage6 + usage8 + usage11
328
+ puts usage1 + usage3 + usage6 + usage8 + usage11 + usage13 + usage15
304
329
  end
305
330
 
306
331
  exit
@@ -360,6 +385,9 @@ HERE
360
385
 
361
386
  opts.on '--name ARG' do |arg|
362
387
  @name = arg
388
+ Kernel.warn '**********'
389
+ Kernel.warn 'Using deprecated option: --name'
390
+ Kernel.warn '**********'
363
391
  end
364
392
 
365
393
  opts.on '--copy-track-names' do
@@ -411,10 +439,12 @@ HERE
411
439
 
412
440
  opts.on '--[no-]10-bit' do |arg|
413
441
  @ten_bit = arg
442
+ @encoder = nil if @encoder == 'copy'
414
443
  end
415
444
 
416
445
  opts.on '--preset ARG' do |arg|
417
446
  @preset = arg
447
+ @encoder = nil if @encoder == 'copy'
418
448
  end
419
449
 
420
450
  opts.on '--decode ARG' do |arg|
@@ -451,6 +481,8 @@ HERE
451
481
  else
452
482
  @target = [arg.to_i, 1].max
453
483
  end
484
+
485
+ @encoder = nil if @encoder == 'copy'
454
486
  end
455
487
 
456
488
  opts.on '--crop ARG' do |arg|
@@ -462,22 +494,27 @@ HERE
462
494
  else
463
495
  fail UsageError, "invalid crop geometry: #{arg}"
464
496
  end
497
+
498
+ @encoder = nil if @encoder == 'copy'
465
499
  end
466
500
 
467
501
  opts.on '--720p' do
468
502
  @max_width = 1280
469
503
  @max_height = 720
504
+ @encoder = nil if @encoder == 'copy'
470
505
  end
471
506
 
472
507
  opts.on '--1080p' do
473
508
  @max_width = 1920
474
509
  @max_height = 1080
510
+ @encoder = nil if @encoder == 'copy'
475
511
  end
476
512
 
477
513
  opts.on '--deinterlace' do
478
514
  @deinterlace = true
479
515
  @detelecine = false
480
516
  @enable_filters = false
517
+ @encoder = nil if @encoder == 'copy' and @decoder_type != :cuvid
481
518
  end
482
519
 
483
520
  opts.on '--rate ARG' do |arg|
@@ -500,6 +537,7 @@ HERE
500
537
 
501
538
  @detelecine = false
502
539
  @enable_filters = false
540
+ @encoder = nil if @encoder == 'copy'
503
541
  end
504
542
 
505
543
  opts.on '--detelecine' do
@@ -507,12 +545,26 @@ HERE
507
545
  @deinterlace = false
508
546
  @rate = nil
509
547
  @enable_filters = false
548
+ @encoder = nil if @encoder == 'copy'
510
549
  end
511
550
 
512
551
  opts.on '--no-filters' do
513
552
  @enable_filters = false
514
553
  end
515
554
 
555
+ opts.on '--copy-video' do
556
+ @encoder = 'copy'
557
+ @hevc = false
558
+ @ten_bit = nil
559
+ @preset = nil
560
+ @target = nil
561
+ @crop = nil
562
+ @rate = nil
563
+ @detelecine = false
564
+ @enable_filters = false
565
+ @burn_subtitle_track = 0
566
+ end
567
+
516
568
  opts.on '--vt-allow-sw' do
517
569
  @encoder = @hevc ? 'hevc_videotoolbox' : 'h264_videotoolbox'
518
570
  @vt_allow_sw = true
@@ -603,7 +655,7 @@ HERE
603
655
  end
604
656
 
605
657
  opts.on '--main-audio ARG' do |arg|
606
- if arg =~ /^([0-9]+)(?:=(surround|stereo))?$/
658
+ if arg =~ /^([0-9]+)(?:=(stereo|surround|original))?$/
607
659
  @audio_selections[0][:track] = $1.to_i
608
660
  @audio_selections[0][:width] = $2.to_sym unless $2.nil?
609
661
  else
@@ -612,7 +664,7 @@ HERE
612
664
  end
613
665
 
614
666
  opts.on '--add-audio ARG' do |arg|
615
- if arg =~ /^([^=]+)(?:=(surround|stereo))?$/
667
+ if arg =~ /^([^=]+)(?:=(stereo|surround|original))?$/
616
668
  scope = $1
617
669
  width = $2
618
670
 
@@ -676,6 +728,8 @@ HERE
676
728
  else
677
729
  fail UsageError, "invalid subtitle track: #{arg}"
678
730
  end
731
+
732
+ @encoder = nil if @encoder == 'copy'
679
733
  end
680
734
  end
681
735
 
@@ -735,7 +789,7 @@ HERE
735
789
  else
736
790
  @encoder.sub!(/^h264/, 'hevc') if @hevc
737
791
 
738
- unless @dry_run or encoders =~ /#{@encoder}/
792
+ unless @dry_run or @encoder == 'copy' or encoders =~ /#{@encoder}/
739
793
  fail "video encoder not available: #{@encoder}"
740
794
  end
741
795
  end
@@ -1241,13 +1295,7 @@ HERE
1241
1295
  overlay_filter = nil
1242
1296
  else
1243
1297
  overlay_filter = "[0:#{burn_subtitle['index']}]overlay"
1244
-
1245
- unless cuvid_decoder.nil?
1246
- Kernel.warn '**********'
1247
- Kernel.warn "burning subtitle disables video decoder: #{cuvid_decoder}"
1248
- Kernel.warn '**********'
1249
- cuvid_decoder = nil
1250
- end
1298
+ cuvid_decoder = nil
1251
1299
  end
1252
1300
 
1253
1301
  deinterlace = @deinterlace
@@ -1267,7 +1315,7 @@ HERE
1267
1315
 
1268
1316
  if deinterlace
1269
1317
  if cuvid_decoder.nil?
1270
- frame_rate_filter = 'yadif=deint=interlaced'
1318
+ frame_rate_filter = 'yadif=deint=interlaced' unless @encoder == 'copy'
1271
1319
  else
1272
1320
  cuvid_options += ['-deint:v', 'adaptive']
1273
1321
  end
@@ -1280,14 +1328,8 @@ HERE
1280
1328
  end
1281
1329
 
1282
1330
  if @detelecine
1283
- unless cuvid_decoder.nil?
1284
- Kernel.warn '**********'
1285
- Kernel.warn "detelecine disables video decoder: #{cuvid_decoder}"
1286
- Kernel.warn '**********'
1287
- cuvid_decoder = nil
1288
- end
1289
-
1290
1331
  frame_rate_filter = 'fieldmatch=order=tff:combmatch=none,decimate'
1332
+ cuvid_decoder = nil
1291
1333
  end
1292
1334
 
1293
1335
  width = video['width'].to_i
@@ -1375,12 +1417,16 @@ HERE
1375
1417
  conversion_filter = nil
1376
1418
  end
1377
1419
 
1378
- filter = overlay_filter.nil? ? '' : overlay_filter
1379
- filter += frame_rate_filter.nil? ? '' : ",#{frame_rate_filter}"
1380
- filter += crop_filter.nil? ? '' : ",#{crop_filter}"
1381
- filter += scale_filter.nil? ? '' : ",#{scale_filter}"
1382
- filter += conversion_filter.nil? ? '' : ",#{conversion_filter}"
1383
- filter.sub!(/^,/, '')
1420
+ if @encoder == 'copy'
1421
+ filter = ''
1422
+ else
1423
+ filter = overlay_filter.nil? ? '' : overlay_filter
1424
+ filter += frame_rate_filter.nil? ? '' : ",#{frame_rate_filter}"
1425
+ filter += crop_filter.nil? ? '' : ",#{crop_filter}"
1426
+ filter += scale_filter.nil? ? '' : ",#{scale_filter}"
1427
+ filter += conversion_filter.nil? ? '' : ",#{conversion_filter}"
1428
+ filter.sub!(/^,/, '')
1429
+ end
1384
1430
 
1385
1431
  if overlay_filter.nil?
1386
1432
  encode_options = [
@@ -1463,8 +1509,12 @@ HERE
1463
1509
  end
1464
1510
 
1465
1511
  Kernel.warn 'Stream mapping:'
1466
- text = "#{sprintf("%2d", video['index'])} = #{@encoder} / #{bitrate} Kbps"
1467
- text += " / #{preset}" unless preset.nil?
1512
+ text = "#{sprintf("%2d", video['index'])} = #{@encoder}"
1513
+
1514
+ unless @encoder == 'copy'
1515
+ text += " / #{bitrate} Kbps"
1516
+ text += " / #{preset}" unless preset.nil?
1517
+ end
1468
1518
 
1469
1519
  unless burn_subtitle.nil?
1470
1520
  text += " / #{sprintf("%d", burn_subtitle['index'])} = #{burn_subtitle['codec_name']} / burn"
@@ -1473,7 +1523,7 @@ HERE
1473
1523
  Kernel.warn text
1474
1524
  encode_options += ['-c:v', @encoder]
1475
1525
  encode_options += ['-pix_fmt:v', (@encoder =~ /(nvenc|qsv)$/ ? 'p010le' : 'yuv420p10le')] if @ten_bit
1476
- encode_options += ['-b:v', "#{bitrate}k"]
1526
+ encode_options += ['-b:v', "#{bitrate}k"] unless @encoder == 'copy'
1477
1527
  encode_options += ['-maxrate:v', "#{maxrate}k"] if @encoder =~ /(nvenc|hevc_qsv|libx26[45])$/
1478
1528
  encode_options += ['-bufsize:v', "#{maxrate}k"] if @encoder =~ /^libx26[45]$/
1479
1529
  encode_options += ['-preset:v', preset] unless preset.nil?
@@ -1544,10 +1594,15 @@ HERE
1544
1594
  encode_options += ['-profile:v', 'high'] if @encoder =~ /^(h264_nvenc|h264_amf|libx264)$/
1545
1595
  end
1546
1596
 
1597
+ unless @encoder == 'copy'
1598
+ encode_options += [
1599
+ '-color_primaries:v', color_primaries,
1600
+ '-color_trc:v', color_trc,
1601
+ '-colorspace:v', colorspace
1602
+ ]
1603
+ end
1604
+
1547
1605
  encode_options += [
1548
- '-color_primaries:v', color_primaries,
1549
- '-color_trc:v', color_trc,
1550
- '-colorspace:v', colorspace,
1551
1606
  '-metadata:s:v', 'title=',
1552
1607
  '-disposition:v', 'default'
1553
1608
  ]
@@ -1577,7 +1632,14 @@ HERE
1577
1632
  audio_tracks = [{
1578
1633
  :stream => main_audio,
1579
1634
  :width => width,
1580
- :bitrate => width == :surround ? @surround_bitrate : @stereo_bitrate
1635
+ :bitrate => case width
1636
+ when :stereo
1637
+ @stereo_bitrate
1638
+ when :surround
1639
+ @surround_bitrate
1640
+ when :original
1641
+ nil
1642
+ end
1581
1643
  }]
1582
1644
 
1583
1645
  titles = {}
@@ -1590,7 +1652,14 @@ HERE
1590
1652
  end
1591
1653
 
1592
1654
  width = selection[:width]
1593
- bitrate = width == :surround ? @surround_bitrate : @stereo_bitrate
1655
+ bitrate = case width
1656
+ when :stereo
1657
+ @stereo_bitrate
1658
+ when :surround
1659
+ @surround_bitrate
1660
+ when :original
1661
+ nil
1662
+ end
1594
1663
 
1595
1664
  unless selection[:track].nil?
1596
1665
  audio_track = 0
@@ -1616,7 +1685,8 @@ HERE
1616
1685
  media_info['streams'].each do |stream|
1617
1686
  next if stream['codec_type'] != 'audio'
1618
1687
 
1619
- if stream.fetch('tags', {}).fetch('language', '') == selection[:language] and
1688
+ if (selection[:language] == 'all' or
1689
+ stream.fetch('tags', {}).fetch('language', '') == selection[:language]) and
1620
1690
  stream['index'] != main_audio['index']
1621
1691
  audio_tracks += [{
1622
1692
  :stream => stream,
@@ -1660,28 +1730,32 @@ HERE
1660
1730
  bitrate = nil
1661
1731
  channels = nil
1662
1732
 
1663
- if track[:width] == :surround
1664
- if codec_name == @surround_encoder or codec_name == 'ac3'
1733
+ if track[:width] == :original
1665
1734
  encoder = 'copy'
1666
- elsif input_channels > 2
1667
- encoder = @surround_encoder
1668
- bitrate = @surround_bitrate
1735
+ else
1736
+ if track[:width] == :surround
1737
+ if codec_name == @surround_encoder or codec_name == 'ac3'
1738
+ encoder = 'copy'
1739
+ elsif input_channels > 2
1740
+ encoder = @surround_encoder
1741
+ bitrate = @surround_bitrate
1742
+ end
1669
1743
  end
1670
- end
1671
1744
 
1672
- if encoder.nil?
1673
- if input_channels <= 2 and (codec_name == 'aac' or
1674
- ((codec_name == @surround_encoder or codec_name == 'ac3') and
1675
- (track[:stream]['bit_rate'].to_i / 1000) <= @stereo_bitrate))
1676
- encoder = 'copy'
1677
- else
1678
- encoder = @stereo_encoder
1679
- bitrate = @stereo_bitrate
1745
+ if encoder.nil?
1746
+ if input_channels <= 2 and (codec_name == 'aac' or
1747
+ ((codec_name == @surround_encoder or codec_name == 'ac3') and
1748
+ (track[:stream]['bit_rate'].to_i / 1000) <= @stereo_bitrate))
1749
+ encoder = 'copy'
1750
+ else
1751
+ encoder = @stereo_encoder
1752
+ bitrate = @stereo_bitrate
1680
1753
 
1681
- if input_channels > 2
1682
- channels = 2
1683
- elsif input_channels == 1
1684
- bitrate = @stereo_bitrate / 2
1754
+ if input_channels > 2
1755
+ channels = 2
1756
+ elsif input_channels == 1
1757
+ bitrate = @stereo_bitrate / 2
1758
+ end
1685
1759
  end
1686
1760
  end
1687
1761
  end
@@ -1764,7 +1838,8 @@ HERE
1764
1838
  media_info['streams'].each do |stream|
1765
1839
  next if stream['codec_type'] != 'subtitle'
1766
1840
 
1767
- if stream.fetch('tags', {}).fetch('language', '') == selection[:language]
1841
+ if (selection[:language] == 'all' or
1842
+ stream.fetch('tags', {}).fetch('language', '') == selection[:language])
1768
1843
  subtitles += [stream]
1769
1844
  end
1770
1845
  end
@@ -1792,9 +1867,6 @@ HERE
1792
1867
  subtitles.each do |subtitle|
1793
1868
  next if (not burn_subtitle.nil?) and burn_subtitle['index'] == subtitle['index']
1794
1869
 
1795
- next if @format == :mp4 and
1796
- (subtitle['codec_name'] == 'hdmv_pgs_subtitle' or subtitle['codec_name'] == 'dvd_subtitle')
1797
-
1798
1870
  force = (index == 0 and not force_subtitle.nil?)
1799
1871
  text = "#{sprintf("%2d", subtitle['index'])} = #{subtitle['codec_name']}"
1800
1872
  text += ' / force' if force
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'other_video_transcoding'
3
- s.version = '0.1.1'
3
+ s.version = '0.2.0'
4
4
  s.required_ruby_version = '>= 2.0'
5
5
  s.summary = 'Other tools to transcode videos.'
6
6
  s.description = <<-HERE
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: other_video_transcoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Melton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-03 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " Other Video Transcoding is a package of tools to transcode videos.\n"
14
14
  email: don@blivet.com