other_video_transcoding 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +4 -0
- data/bin/ask-ffmpeg-log +4 -1
- data/bin/other-transcode +250 -39
- data/other_video_transcoding.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd29131688402599d3de0635a670005c8f32e7bda45f3b314dd7b47948d55be3
|
4
|
+
data.tar.gz: 1af9708f4b3639fd81d935b9c96ec120ecdc63411caa00a94783d44c2fb4d1f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed431c314fc122ac855827c7ca831b67d1e7b5cb7dfe89500ce7bff6ec410a4e6893fc308f7724d8cb070dcc3c38eec92fbb57acd6e860690925c0691cde13a
|
7
|
+
data.tar.gz: 1442f616f7f8aed6aaafd2104f503c29e3bfa4c37a5f139c832f99b3a31c8f027f2636d7d2671734170d08dc97df53eae1b3d96270cef0badbf56d88ef95ca6c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
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.3.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.3.0)
|
6
|
+
|
7
|
+
Thursday, February 27, 2020
|
8
|
+
|
9
|
+
* Add a `--scan` option to `other-transcode`. This prints media information and then exits, allowing easy identification of track numbers and formats. Via [ #11](https://github.com/donmelton/other_video_transcoding/issues/11).
|
10
|
+
* Add a `--mono-bitrate` option to `other-transcode`. This sets the mono audio bitrate, which is otherwise 50% of the stereo bitrate.
|
11
|
+
* Raise the maximum bitrates for audio in AAC format to 320 Kbps for stereo and 256 Kbps for mono. The default birates remain the same.
|
12
|
+
* Add a `--all-eac3` option to `other-transcode`. This uses the Dolby Digital Plus (Enhanced AC-3) format for all transcoded audio. The behavior of the `--eac3` option, which uses Dolby Digital Plus for surround audio only, remains the same.
|
13
|
+
* Add a `--keep-ac3-stereo` option to `other-transcode`. This copies stereo and mono audio in AC-3 format even when the original source bitrate is above the output transcoding bitrate.
|
14
|
+
* Add a `--pass-dts` option to `other-transcode`. This enables passthrough of audio in DTS and DTS-ES formats. However, such audio also in surround format will still be transcoded if that audio is output to a stereo-width track.
|
15
|
+
* Add `--rc-maxrate` and `--rc-bufsize` options to `other-transcode`. These set the ratecontrol maximum rate and/or the buffer size as a multiple of the video bitrate target, but only for certain encoders and ratecontrol systems.
|
16
|
+
* Add a `--x264-mbtree` option to `other-transcode`. This uses macroblock-tree ratecontrol and disables AVBR if in use.
|
17
|
+
* In order to ensure compatible H.264 levels, limit the number of reference frames when using the `x264` encoder with slower presets.
|
18
|
+
* Remove the deprecated `--name` option of `other-transcode`.
|
19
|
+
* Add a link to a Docker container for Linux in the "README" document. Thanks, @ttyS0!
|
20
|
+
|
5
21
|
## [0.2.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.2.0)
|
6
22
|
|
7
23
|
Monday, January 13, 2020
|
data/README.md
CHANGED
@@ -62,6 +62,10 @@ See "[Download FFmpeg](https://ffmpeg.org/download.html)," "[MKVToolNix Download
|
|
62
62
|
|
63
63
|
Additional documentation for installing these programs on Windows is available in the [wiki](https://github.com/donmelton/other_video_transcoding/wiki/Windows).
|
64
64
|
|
65
|
+
A [Docker](https://en.wikipedia.org/wiki/Docker_(software)) container for Linux, including installation instructions, is available here:
|
66
|
+
|
67
|
+
https://github.com/ttyS0/docker-transcode-vaapi
|
68
|
+
|
65
69
|
On macOS, all of these programs can be easily installed via [Homebrew](http://brew.sh/), an optional package manager:
|
66
70
|
|
67
71
|
brew install ffmpeg
|
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.
|
19
|
+
ask-ffmpeg-log 0.3.0
|
20
20
|
Copyright (c) 2019-2020 Don Melton
|
21
21
|
HERE
|
22
22
|
end
|
@@ -65,6 +65,7 @@ HERE
|
|
65
65
|
end
|
66
66
|
|
67
67
|
fail UsageError, 'missing argument' if ARGV.empty?
|
68
|
+
|
68
69
|
ARGV.each { |arg| process_input arg }
|
69
70
|
complete
|
70
71
|
exit
|
@@ -92,10 +93,12 @@ HERE
|
|
92
93
|
if File.directory? input
|
93
94
|
logs = Dir[input + File::SEPARATOR + '*.log']
|
94
95
|
fail "does not contain `.log` files: #{input}" if logs.empty?
|
96
|
+
|
95
97
|
@logs += logs
|
96
98
|
@paths << input
|
97
99
|
else
|
98
100
|
fail "not a `.log` file: #{input}" unless File.extname(input) == '.log'
|
101
|
+
|
99
102
|
@logs << File.absolute_path(input)
|
100
103
|
@paths << File.dirname(input)
|
101
104
|
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.
|
21
|
+
other-transcode 0.3.0
|
22
22
|
Copyright (c) 2019-2020 Don Melton
|
23
23
|
HERE
|
24
24
|
end
|
@@ -51,6 +51,7 @@ HERE
|
|
51
51
|
<<HERE
|
52
52
|
Output options:
|
53
53
|
--debug increase diagnostic information
|
54
|
+
--scan print media information and exit
|
54
55
|
--preview-crop show commands to preview detected video crop and exit
|
55
56
|
HERE
|
56
57
|
end
|
@@ -130,6 +131,9 @@ HERE
|
|
130
131
|
|
131
132
|
def usage10
|
132
133
|
<<HERE
|
134
|
+
--rc-maxrate FACTOR, --rc-bufsize FACTOR
|
135
|
+
set ratecontrol maximum rate and/or buffer size
|
136
|
+
as multiple of video bitrate target
|
133
137
|
--copy-video disable transcoding and copy original video track
|
134
138
|
|
135
139
|
Apple Video Toolbox encoder options:
|
@@ -171,6 +175,7 @@ Video Acceleration API encoder options:
|
|
171
175
|
|
172
176
|
x264 software video encoder options:
|
173
177
|
--x264-avbr use average variable bitrate (AVBR) ratecontrol
|
178
|
+
--x264-mbtree use macroblock-tree ratecontrol (disables AVBR if in use)
|
174
179
|
--x264-quick increase encoding speed by 70-80%
|
175
180
|
with no easily perceptible loss in video quality
|
176
181
|
(avoids quality problems with some encoder presets)
|
@@ -222,7 +227,34 @@ HERE
|
|
222
227
|
set surround audio bitrate (default: 640)
|
223
228
|
--stereo-bitrate BITRATE
|
224
229
|
set stereo audio bitrate (default: 256)
|
230
|
+
HERE
|
231
|
+
end
|
232
|
+
|
233
|
+
def usage16
|
234
|
+
<<HERE
|
235
|
+
--mono-bitrate BITRATE
|
236
|
+
set mono audio bitrate (default: 50% of stereo bitrate)
|
237
|
+
HERE
|
238
|
+
end
|
239
|
+
|
240
|
+
def usage17
|
241
|
+
<<HERE
|
225
242
|
--eac3 use Enhanced AC-3 format for surround audio
|
243
|
+
HERE
|
244
|
+
end
|
245
|
+
|
246
|
+
def usage18
|
247
|
+
<<HERE
|
248
|
+
--all-eac3 " " " " " all audio
|
249
|
+
--keep-ac3-stereo
|
250
|
+
copy stereo and mono audio in AC-3 format
|
251
|
+
even when orginal bitrate is above transcoding bitrate
|
252
|
+
--pass-dts enable passthrough of audio in DTS and DTS-ES formats
|
253
|
+
HERE
|
254
|
+
end
|
255
|
+
|
256
|
+
def usage19
|
257
|
+
<<HERE
|
226
258
|
|
227
259
|
Subtitle options:
|
228
260
|
--add-subtitle TRACK[=forced]|auto|all|LANGUAGE|STRING
|
@@ -254,10 +286,10 @@ HERE
|
|
254
286
|
@position = nil
|
255
287
|
@duration = nil
|
256
288
|
@debug = false
|
289
|
+
@scan = false
|
257
290
|
@detect = false
|
258
291
|
@preview = false
|
259
292
|
@format = :mkv
|
260
|
-
@name = nil
|
261
293
|
@copy_track_names = false
|
262
294
|
@max_muxing_queue_size = nil
|
263
295
|
@dry_run = false
|
@@ -279,6 +311,8 @@ HERE
|
|
279
311
|
@rate = nil
|
280
312
|
@detelecine = false
|
281
313
|
@enable_filters = true
|
314
|
+
@maxrate = nil
|
315
|
+
@bufsize = nil
|
282
316
|
@vt_allow_sw = false
|
283
317
|
@nvenc_spatial_aq = nil
|
284
318
|
@nvenc_temporal_aq = nil
|
@@ -294,6 +328,7 @@ HERE
|
|
294
328
|
@amf_bframes = nil
|
295
329
|
@vaapi_compression = nil
|
296
330
|
@x264_avbr = false
|
331
|
+
@x264_mbtree = false
|
297
332
|
@x264_quick = false
|
298
333
|
@audio_selections = [{
|
299
334
|
:track => 1,
|
@@ -303,8 +338,11 @@ HERE
|
|
303
338
|
}]
|
304
339
|
@surround_bitrate = 640
|
305
340
|
@stereo_bitrate = 256
|
341
|
+
@mono_bitrate = nil
|
306
342
|
@surround_encoder = 'ac3'
|
307
343
|
@stereo_encoder = nil
|
344
|
+
@keep_ac3_stereo = false
|
345
|
+
@pass_dts = false
|
308
346
|
@subtitle_selections = []
|
309
347
|
@auto_add_subtitle = false
|
310
348
|
@burn_subtitle_track = 0
|
@@ -320,12 +358,15 @@ HERE
|
|
320
358
|
when 'full'
|
321
359
|
puts usage1 + usage2 + usage3 + usage4 + usage5 + usage6 +
|
322
360
|
usage7 + usage8 + usage9 + usage10 + usage11 + usage12 +
|
323
|
-
usage13 + usage14 + usage15
|
361
|
+
usage13 + usage14 + usage15 + usage16 + usage17 +
|
362
|
+
usage18 + usage19
|
324
363
|
when 'more'
|
325
364
|
puts usage1 + usage2 + usage3 + usage4 + usage6 + usage7 +
|
326
|
-
usage8 + usage9 + usage11 + usage13 + usage15
|
365
|
+
usage8 + usage9 + usage11 + usage13 + usage15 + usage16 +
|
366
|
+
usage17 + usage18 + usage19
|
327
367
|
else
|
328
|
-
puts usage1 + usage3 + usage6 + usage8 + usage11 + usage13 +
|
368
|
+
puts usage1 + usage3 + usage6 + usage8 + usage11 + usage13 +
|
369
|
+
usage15 + usage17 + usage19
|
329
370
|
end
|
330
371
|
|
331
372
|
exit
|
@@ -341,6 +382,7 @@ HERE
|
|
341
382
|
end
|
342
383
|
|
343
384
|
fail UsageError, 'missing argument' if ARGV.empty?
|
385
|
+
|
344
386
|
configure ARGV.first
|
345
387
|
ARGV.each { |arg| process_input arg }
|
346
388
|
exit
|
@@ -369,6 +411,10 @@ HERE
|
|
369
411
|
@debug = true
|
370
412
|
end
|
371
413
|
|
414
|
+
opts.on '--scan' do
|
415
|
+
@scan = true
|
416
|
+
end
|
417
|
+
|
372
418
|
opts.on '--preview-crop' do
|
373
419
|
@detect = true
|
374
420
|
@preview = true
|
@@ -383,13 +429,6 @@ HERE
|
|
383
429
|
@format = :mp4
|
384
430
|
end
|
385
431
|
|
386
|
-
opts.on '--name ARG' do |arg|
|
387
|
-
@name = arg
|
388
|
-
Kernel.warn '**********'
|
389
|
-
Kernel.warn 'Using deprecated option: --name'
|
390
|
-
Kernel.warn '**********'
|
391
|
-
end
|
392
|
-
|
393
432
|
opts.on '--copy-track-names' do
|
394
433
|
@copy_track_names = true
|
395
434
|
end
|
@@ -552,6 +591,16 @@ HERE
|
|
552
591
|
@enable_filters = false
|
553
592
|
end
|
554
593
|
|
594
|
+
opts.on '--rc-maxrate ARG', Float do |arg|
|
595
|
+
@maxrate = arg
|
596
|
+
@encoder = nil if @encoder == 'copy'
|
597
|
+
end
|
598
|
+
|
599
|
+
opts.on '--rc-bufsize ARG', Float do |arg|
|
600
|
+
@bufsize = arg
|
601
|
+
@encoder = nil if @encoder == 'copy'
|
602
|
+
end
|
603
|
+
|
555
604
|
opts.on '--copy-video' do
|
556
605
|
@encoder = 'copy'
|
557
606
|
@hevc = false
|
@@ -645,6 +694,14 @@ HERE
|
|
645
694
|
@encoder = 'libx264'
|
646
695
|
@hevc = false
|
647
696
|
@x264_avbr = true
|
697
|
+
@x264_mbtree = false
|
698
|
+
end
|
699
|
+
|
700
|
+
opts.on '--x264-mbtree' do
|
701
|
+
@encoder = 'libx264'
|
702
|
+
@hevc = false
|
703
|
+
@x264_mbtree = true
|
704
|
+
@x264_avbr = false
|
648
705
|
end
|
649
706
|
|
650
707
|
opts.on '--x264-quick' do
|
@@ -699,10 +756,27 @@ HERE
|
|
699
756
|
@stereo_bitrate = arg
|
700
757
|
end
|
701
758
|
|
759
|
+
opts.on '--mono-bitrate ARG', Integer do |arg|
|
760
|
+
@mono_bitrate = arg
|
761
|
+
end
|
762
|
+
|
702
763
|
opts.on '--eac3' do
|
703
764
|
@surround_encoder = 'eac3'
|
704
765
|
end
|
705
766
|
|
767
|
+
opts.on '--all-eac3' do
|
768
|
+
@surround_encoder = 'eac3'
|
769
|
+
@stereo_encoder = 'eac3'
|
770
|
+
end
|
771
|
+
|
772
|
+
opts.on '--keep-ac3-stereo' do
|
773
|
+
@keep_ac3_stereo = true
|
774
|
+
end
|
775
|
+
|
776
|
+
opts.on '--pass-dts' do
|
777
|
+
@pass_dts = true
|
778
|
+
end
|
779
|
+
|
706
780
|
opts.on '--add-subtitle ARG' do |arg|
|
707
781
|
if arg =~ /^([0-9]+)(?:=(forced))?$|^(auto)$|^([a-z]{3})$|^(.*)$/
|
708
782
|
@subtitle_selections += [{
|
@@ -754,7 +828,13 @@ HERE
|
|
754
828
|
@audio_selections.uniq!
|
755
829
|
@subtitle_selections.uniq!
|
756
830
|
@surround_bitrate = [[@surround_bitrate, 256].max, (@surround_encoder == 'ac3' ? 640 : 768)].min
|
757
|
-
@stereo_bitrate = [[@stereo_bitrate, 128].max,
|
831
|
+
@stereo_bitrate = [[@stereo_bitrate, 128].max, (@stereo_encoder == 'eac3' ? 768 : 320)].min
|
832
|
+
|
833
|
+
if @mono_bitrate.nil?
|
834
|
+
@mono_bitrate = @stereo_bitrate / 2
|
835
|
+
else
|
836
|
+
@mono_bitrate = [[@mono_bitrate, 64].max, (@stereo_encoder == 'eac3' ? 768 : 256)].min
|
837
|
+
end
|
758
838
|
|
759
839
|
[
|
760
840
|
['ffprobe', '-loglevel', 'quiet', '-version'],
|
@@ -764,7 +844,7 @@ HERE
|
|
764
844
|
verify_tool_availability command
|
765
845
|
end
|
766
846
|
|
767
|
-
return if @detect
|
847
|
+
return if @scan or @detect
|
768
848
|
|
769
849
|
encoders = find_encoders
|
770
850
|
|
@@ -887,9 +967,8 @@ HERE
|
|
887
967
|
def process_input(path)
|
888
968
|
seconds = Time.now.tv_sec
|
889
969
|
|
890
|
-
unless @detect
|
891
|
-
output_path =
|
892
|
-
'.' + @format.to_s
|
970
|
+
unless @scan or @detect
|
971
|
+
output_path = File.basename(path, '.*') + '.' + @format.to_s
|
893
972
|
fail "output file already exists: #{output_path}" if File.exist? output_path
|
894
973
|
|
895
974
|
log_path = output_path + '.log'
|
@@ -901,6 +980,11 @@ HERE
|
|
901
980
|
|
902
981
|
media_info = scan_media(path)
|
903
982
|
|
983
|
+
if @scan
|
984
|
+
print_media_info media_info
|
985
|
+
return
|
986
|
+
end
|
987
|
+
|
904
988
|
video, burn_subtitle = get_video_streams(media_info)
|
905
989
|
fail "video track not found: #{path}" if video.nil?
|
906
990
|
|
@@ -911,7 +995,7 @@ HERE
|
|
911
995
|
crop = detect_crop(media_info, video)
|
912
996
|
|
913
997
|
if @detect
|
914
|
-
present_crop
|
998
|
+
present_crop crop, path
|
915
999
|
return
|
916
1000
|
else
|
917
1001
|
Kernel.warn "crop = #{crop[:width]}:#{crop[:height]}:#{crop[:x]}:#{crop[:y]}"
|
@@ -944,7 +1028,7 @@ HERE
|
|
944
1028
|
'-stats'
|
945
1029
|
] + time_options +
|
946
1030
|
decode_options + [
|
947
|
-
'-i',
|
1031
|
+
'-i', path
|
948
1032
|
] + (@max_muxing_queue_size.nil? ? [] : ['-max_muxing_queue_size', @max_muxing_queue_size.to_s]) +
|
949
1033
|
encode_options +
|
950
1034
|
get_audio_options(media_info) +
|
@@ -995,12 +1079,12 @@ HERE
|
|
995
1079
|
FileUtils.mv tmp_log_path, log_path
|
996
1080
|
end
|
997
1081
|
|
998
|
-
assemble_log
|
1082
|
+
assemble_log log_path, output
|
999
1083
|
|
1000
1084
|
if @format == :mp4
|
1001
1085
|
Kernel.warn 'Done.'
|
1002
1086
|
else
|
1003
|
-
add_track_statistics_tags
|
1087
|
+
add_track_statistics_tags output_path
|
1004
1088
|
end
|
1005
1089
|
|
1006
1090
|
Kernel.warn "\nElapsed time: #{seconds_to_time(Time.now.tv_sec - seconds)}\n\n"
|
@@ -1040,6 +1124,93 @@ HERE
|
|
1040
1124
|
media_info
|
1041
1125
|
end
|
1042
1126
|
|
1127
|
+
def print_media_info(media_info)
|
1128
|
+
video = nil
|
1129
|
+
audio_streams = []
|
1130
|
+
subtitles = []
|
1131
|
+
|
1132
|
+
media_info['streams'].each do |stream|
|
1133
|
+
case stream['codec_type']
|
1134
|
+
when 'video'
|
1135
|
+
video = stream if video.nil?
|
1136
|
+
when 'audio'
|
1137
|
+
audio_streams += [stream]
|
1138
|
+
when 'subtitle'
|
1139
|
+
subtitles += [stream]
|
1140
|
+
end
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
puts media_info['format']['filename']
|
1144
|
+
size = "#{video['width']} x #{video['height']}"
|
1145
|
+
print " format = #{video['codec_name']} / #{size} / #{video['avg_frame_rate']} fps"
|
1146
|
+
bitrate = get_bitrate(video)
|
1147
|
+
puts bitrate.nil? ? '' : " / #{bitrate} Kbps"
|
1148
|
+
duration = media_info['format']['duration'].to_f
|
1149
|
+
time = seconds_to_time(duration.to_i)
|
1150
|
+
milliseconds = duration.to_s.sub(/^[0-9]+(\.[0-9]+)$/, '\1')
|
1151
|
+
time += milliseconds unless milliseconds == '.0'
|
1152
|
+
puts " duration = #{time}"
|
1153
|
+
index = 0
|
1154
|
+
|
1155
|
+
audio_streams.each do |stream|
|
1156
|
+
index += 1
|
1157
|
+
puts "\##{index} audio:"
|
1158
|
+
codec_name = stream['codec_name']
|
1159
|
+
print " format = #{codec_name}"
|
1160
|
+
|
1161
|
+
if codec_name == 'dts'
|
1162
|
+
profile = stream.fetch('profile', 'DTS')
|
1163
|
+
print " (#{profile})" unless profile == 'DTS'
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
print ' / '
|
1167
|
+
layout = stream.fetch('channel_layout', '')
|
1168
|
+
|
1169
|
+
if layout.empty?
|
1170
|
+
channels = stream['channels'].to_i
|
1171
|
+
print "#{channels} " + (channels > 1 ? 'channels' : 'channel')
|
1172
|
+
else
|
1173
|
+
print "#{layout}"
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
bitrate = get_bitrate(stream)
|
1177
|
+
puts bitrate.nil? ? '' : " / #{bitrate} Kbps"
|
1178
|
+
puts " language = #{stream.fetch('tags', {}).fetch('language', '')}"
|
1179
|
+
title = stream.fetch('tags', {}).fetch('title', '')
|
1180
|
+
puts " title = #{title}" unless title.empty?
|
1181
|
+
end
|
1182
|
+
|
1183
|
+
index = 0
|
1184
|
+
|
1185
|
+
subtitles.each do |stream|
|
1186
|
+
index += 1
|
1187
|
+
puts "\##{index} subtitle:"
|
1188
|
+
print " format = #{stream['codec_name']}"
|
1189
|
+
frames = stream.fetch('tags', {}).fetch('NUMBER_OF_FRAMES-eng', '')
|
1190
|
+
puts frames.empty? ? '' : " / #{frames} " + (frames == 1 ? 'frame' : 'frames')
|
1191
|
+
puts " language = #{stream.fetch('tags', {}).fetch('language', '')}"
|
1192
|
+
title = stream.fetch('tags', {}).fetch('title', '')
|
1193
|
+
puts " title = #{title}" unless title.empty?
|
1194
|
+
default = (stream['disposition']['default'] == 1)
|
1195
|
+
forced = (stream['disposition']['forced'] == 1)
|
1196
|
+
|
1197
|
+
if default or forced
|
1198
|
+
puts ' flags = ' +
|
1199
|
+
(default ? 'default' : '') +
|
1200
|
+
((default and forced) ? ' / ' : '') +
|
1201
|
+
(forced ? 'forced' : '')
|
1202
|
+
end
|
1203
|
+
end
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
def get_bitrate(stream)
|
1207
|
+
bitrate = stream.fetch('bit_rate', '')
|
1208
|
+
bitrate = stream.fetch('tags', {}).fetch('BPS-eng', '') if bitrate.empty?
|
1209
|
+
return nil if bitrate.empty?
|
1210
|
+
|
1211
|
+
bitrate.to_i / 1000
|
1212
|
+
end
|
1213
|
+
|
1043
1214
|
def detect_crop(media_info, video)
|
1044
1215
|
Kernel.warn 'Detecting crop...'
|
1045
1216
|
duration = media_info['format']['duration'].to_f
|
@@ -1460,15 +1631,19 @@ HERE
|
|
1460
1631
|
if width > 1920 or height > 1080
|
1461
1632
|
bitrate = @target_2160p
|
1462
1633
|
max_bitrate = 40000
|
1634
|
+
max_dpb_mbs = 184320
|
1463
1635
|
elsif width > 1280 or height > 720
|
1464
1636
|
bitrate = @target_1080p
|
1465
1637
|
max_bitrate = 20000
|
1638
|
+
max_dpb_mbs = 32768
|
1466
1639
|
elsif width > 720 or height > 576
|
1467
1640
|
bitrate = @target_720p
|
1468
1641
|
max_bitrate = 10000
|
1642
|
+
max_dpb_mbs = 18000
|
1469
1643
|
else
|
1470
1644
|
bitrate = @target_480p
|
1471
1645
|
max_bitrate = 5000
|
1646
|
+
max_dpb_mbs = 8100
|
1472
1647
|
|
1473
1648
|
unless hdr
|
1474
1649
|
color_primaries = pal ? 'bt470bg' : 'smpte170m'
|
@@ -1478,7 +1653,22 @@ HERE
|
|
1478
1653
|
|
1479
1654
|
bitrate = @target unless @target.nil?
|
1480
1655
|
bitrate = [bitrate, max_bitrate].min
|
1481
|
-
maxrate =
|
1656
|
+
maxrate = 0
|
1657
|
+
bufsize = 0
|
1658
|
+
|
1659
|
+
if @encoder =~ /(nvenc|hevc_qsv|libx26[45])$/
|
1660
|
+
if @maxrate.nil?
|
1661
|
+
maxrate = bitrate * 3
|
1662
|
+
else
|
1663
|
+
maxrate = [[(bitrate * @maxrate).to_i, (bitrate * 1.5).to_i].max, bitrate * 3].min
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
if @bufsize.nil?
|
1667
|
+
bufsize = maxrate if @encoder =~ /^libx26[45]$/
|
1668
|
+
else
|
1669
|
+
bufsize = [[(bitrate * @bufsize).to_i, bitrate].max, bitrate * 4].min
|
1670
|
+
end
|
1671
|
+
end
|
1482
1672
|
|
1483
1673
|
if @preset.nil? or @preset == 'none'
|
1484
1674
|
preset = nil
|
@@ -1505,6 +1695,7 @@ HERE
|
|
1505
1695
|
end
|
1506
1696
|
|
1507
1697
|
fail "invalid preset for encoder: #{@preset}" unless valid
|
1698
|
+
|
1508
1699
|
preset = @preset
|
1509
1700
|
end
|
1510
1701
|
|
@@ -1524,8 +1715,8 @@ HERE
|
|
1524
1715
|
encode_options += ['-c:v', @encoder]
|
1525
1716
|
encode_options += ['-pix_fmt:v', (@encoder =~ /(nvenc|qsv)$/ ? 'p010le' : 'yuv420p10le')] if @ten_bit
|
1526
1717
|
encode_options += ['-b:v', "#{bitrate}k"] unless @encoder == 'copy'
|
1527
|
-
encode_options += ['-maxrate:v', "#{maxrate}k"] if
|
1528
|
-
encode_options += ['-bufsize:v', "#{
|
1718
|
+
encode_options += ['-maxrate:v', "#{maxrate}k"] if maxrate > 0
|
1719
|
+
encode_options += ['-bufsize:v', "#{bufsize}k"] if bufsize > 0
|
1529
1720
|
encode_options += ['-preset:v', preset] unless preset.nil?
|
1530
1721
|
encode_options += ['-allow_sw:v', '1'] if @encoder =~ /videotoolbox$/ and @vt_allow_sw
|
1531
1722
|
|
@@ -1579,14 +1770,31 @@ HERE
|
|
1579
1770
|
|
1580
1771
|
if @encoder == 'libx264'
|
1581
1772
|
encode_options += ['-x264opts:v', 'ratetol=inf'] if @x264_avbr
|
1582
|
-
encode_options += ['-mbtree:v', '0']
|
1773
|
+
encode_options += ['-mbtree:v', '0'] unless @x264_mbtree
|
1583
1774
|
|
1584
|
-
if @preset.nil?
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1775
|
+
if @preset.nil?
|
1776
|
+
if @x264_quick
|
1777
|
+
encode_options += [
|
1778
|
+
'-refs:v', '1',
|
1779
|
+
'-rc-lookahead:v', '30',
|
1780
|
+
'-partitions:v', 'none'
|
1781
|
+
]
|
1782
|
+
end
|
1783
|
+
else
|
1784
|
+
max_refs = [(max_dpb_mbs / (((width + 15) / 16) * ((height + 15) / 16))), 16].min
|
1785
|
+
|
1786
|
+
case @preset
|
1787
|
+
when 'slow'
|
1788
|
+
refs = 5
|
1789
|
+
when 'slower'
|
1790
|
+
refs = 8
|
1791
|
+
when 'veryslow', 'placebo'
|
1792
|
+
refs = 16
|
1793
|
+
else
|
1794
|
+
refs = 0
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
encode_options += ['-refs:v', max_refs.to_s] if refs > max_refs
|
1590
1798
|
end
|
1591
1799
|
end
|
1592
1800
|
|
@@ -1652,6 +1860,7 @@ HERE
|
|
1652
1860
|
end
|
1653
1861
|
|
1654
1862
|
width = selection[:width]
|
1863
|
+
|
1655
1864
|
bitrate = case width
|
1656
1865
|
when :stereo
|
1657
1866
|
@stereo_bitrate
|
@@ -1733,8 +1942,12 @@ HERE
|
|
1733
1942
|
if track[:width] == :original
|
1734
1943
|
encoder = 'copy'
|
1735
1944
|
else
|
1945
|
+
dts = (codec_name == 'dts' and track[:stream].fetch('profile', 'DTS') =~ /^DTS(?:-ES)?$/)
|
1946
|
+
|
1736
1947
|
if track[:width] == :surround
|
1737
|
-
if
|
1948
|
+
if codec_name == @surround_encoder or
|
1949
|
+
codec_name == 'ac3' or
|
1950
|
+
(@pass_dts and dts)
|
1738
1951
|
encoder = 'copy'
|
1739
1952
|
elsif input_channels > 2
|
1740
1953
|
encoder = @surround_encoder
|
@@ -1743,9 +1956,10 @@ HERE
|
|
1743
1956
|
end
|
1744
1957
|
|
1745
1958
|
if encoder.nil?
|
1746
|
-
if
|
1959
|
+
if input_channels <= 2 and (codec_name == 'aac' or
|
1747
1960
|
((codec_name == @surround_encoder or codec_name == 'ac3') and
|
1748
|
-
(track[:stream]['bit_rate'].to_i / 1000) <= @stereo_bitrate))
|
1961
|
+
(@keep_ac3_stereo or (track[:stream]['bit_rate'].to_i / 1000) <= @stereo_bitrate)) or
|
1962
|
+
(@pass_dts and dts))
|
1749
1963
|
encoder = 'copy'
|
1750
1964
|
else
|
1751
1965
|
encoder = @stereo_encoder
|
@@ -1754,7 +1968,7 @@ HERE
|
|
1754
1968
|
if input_channels > 2
|
1755
1969
|
channels = 2
|
1756
1970
|
elsif input_channels == 1
|
1757
|
-
bitrate = @
|
1971
|
+
bitrate = @mono_bitrate
|
1758
1972
|
end
|
1759
1973
|
end
|
1760
1974
|
end
|
@@ -1856,10 +2070,7 @@ HERE
|
|
1856
2070
|
end
|
1857
2071
|
end
|
1858
2072
|
|
1859
|
-
unless force_subtitle.nil?
|
1860
|
-
subtitles = [force_subtitle] + subtitles
|
1861
|
-
end
|
1862
|
-
|
2073
|
+
subtitles = [force_subtitle] + subtitles unless force_subtitle.nil?
|
1863
2074
|
subtitles.uniq!
|
1864
2075
|
options = []
|
1865
2076
|
index = 0
|
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2020-02-28 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
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
48
|
+
rubygems_version: 3.1.2
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Other tools to transcode videos.
|