other_video_transcoding 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/bin/ask-ffmpeg-log +1 -1
- data/bin/other-transcode +162 -188
- data/other_video_transcoding-0.8.0.gem +0 -0
- data/other_video_transcoding.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e79f218a2cdbb3a930db25fd5d5b94e6294fec90f451bb979457c68ae13a82
|
4
|
+
data.tar.gz: cc6b33de67d3da5fb80d59634181ccdd89aa539cb4d35b5d5729bd3b4ee5dae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 638f9905c7df90b4c7921ae6a1d4b54e93f264c119a2599356ce911132b9688eba83edfe5ab2a0d6037326ce0c62c7aa4813792da45e15840f06d38bff1f999c
|
7
|
+
data.tar.gz: e213384ceb4e30a711e0a161ec371e72cb53b0d8d562ee7dc73dd8aade72dca2df1e8855800643dc36afe4cfa4356ae55a40fd80b2de503944261e7042388f73
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,39 @@
|
|
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.9.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.9.0)
|
6
|
+
|
7
|
+
Saturday, June 5, 2021
|
8
|
+
|
9
|
+
Nvidia encoders:
|
10
|
+
|
11
|
+
* Add a `--nvenc-recommended` option to `other-transcode` which easily and optimally configures the Nvidia H.264 and HEVC video encoders, equivalent to using:
|
12
|
+
* `--nvenc-spatial-aq --nvenc-lookahead 32 --nvenc-bframe-refs middle`
|
13
|
+
* The `--nvenc-bframe-refs` option is also new and using `middle` as its argument increases compression efficiency. However, it's not supported on all Nvidia hardware. Which means, neither is the `--nvenc-recommended` option.
|
14
|
+
* So, using `--nvenc-recommended` for H.264 encoding requires at minimum a fourth generation Pascal-based GPU like the GTX 1080. And using it for HEVC encoding requires at minimum a more recent sixth generation Turing-based model like the GTX 1660 or RTX 2070.
|
15
|
+
* Add a `--nvenc-cq` option to `other-transcode` to allow constant quality (CQ) ratecontrol. This option ignores the target video bitrate and takes a single numerical argument between `1` and `51` with lower values indicating higher quality. However, only values between `25` and `30` are really practical for 1080p content. It's recommended to start with `--nvenc-cq 28` and adjust as needed. Fractional values are also supported.
|
16
|
+
* While CQ ratecontrol can adapt better to extremely dynamic content compared to the default average bitrate (ABR) ratecontrol system, the output bitrates produced by CQ can vary significantly and it can be slightly more prone to color banding with the H.264 encoder. So, for now, consider the `--nvenc-cq` option an experimental feature.
|
17
|
+
* Deprecate the `--nvenc-rc-mode` option in `other-transcode` because maximum rate and buffer size values are already specified so an explicit ratecontrol mode is not required.
|
18
|
+
|
19
|
+
Audio:
|
20
|
+
|
21
|
+
* Modify `other-transcode` to no longer explicitly set audio bitrates and instead rely on the defaults from the audio encoders included with `ffmpeg`. This is being done to both simplify the code in `other-transcode` and to leverage the judgement of the audio encoder developers, which means:
|
22
|
+
* AC-3 surround audio is lowered from 640 Kbps to 448 Kbps.
|
23
|
+
* Dolby Digital Plus (Enhanced AC-3) surround audio is raised from 384 Kbps to 448 Kbps.
|
24
|
+
* AAC stereo audio is lowered from 256 Kbps to 128 Kbps when using the native `ffmpeg` or Apple AudioToolbox encoders.
|
25
|
+
* If desired, use the `--surround-bitrate` and `--stereo-bitrate` options to restore the previous default audio bitrates.
|
26
|
+
* Add a `--aac-only` option to `other-transcode` to force transcoding of all audio into AAC format, copying only tracks which are already in that format. Surround tracks are converted to a 5.1-channel AAC format at 341 Kbps when using the native `ffmpeg` encoder. This channel layout is compatible with most playback devices. Allowing more than 5.1 channels would significantly reduce playback compatibility.
|
27
|
+
* Deprecate the `--aac-stereo` option in `other-transcode` and replace with a new `--eac3-aac` option, which uses Dolby Digital Plus format only for surround audio with AAC format for stereo audio. Since the `--aac-stereo` option only made sense when used in combination with the `--eac3` option, this makes `--eac3-aac` more convenient.
|
28
|
+
|
29
|
+
Other changes:
|
30
|
+
|
31
|
+
* Change the default ratecontrol maximum rate and buffer size values in `other-transcode`, as well as how those values increased when the target video bitrate is increased. The default values now also differ depending on whether the output video is in H.264 or HEVC format.
|
32
|
+
* Modify the `--rc-maxrate` and `--rc-bufsize` options in `other-transcode` to allow specific bitrates as arguments and not just multiples of the video bitrate target. These options are most useful for lowering maximum rate and buffer size values. To raise those values, increase the target video bitrate instead.
|
33
|
+
* Change the pixel format and force a Main 10 video profile in `other-transcode` when using the Apple VideoToolbox encoder to create output with a 10-bit color depth. Correct generation of 10-bit output requires macOS Big Sur or later.
|
34
|
+
* Modify `other-transcode` to copy the three basic color properties (primaries, transer and space) from the input to the output when those properties are availabe. Otherwise use some sensible defaults.
|
35
|
+
* Modify `other-transcode` to force a H.264 level when using `--x264` with slower presets. This ensures that the `x264` encoder continues to generate a video stream compatible with most playback devices when those presets are used.
|
36
|
+
* Modify `other-transcode` to remove the hack which avoids using the Matroksa muxer `-disposition` option in old versions of `ffmpeg`. This means version 4.3 or later of `ffmpeg` is now required to run `other-transcode`.
|
37
|
+
|
5
38
|
## [0.8.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.8.0)
|
6
39
|
|
7
40
|
Saturday, February 13, 2021
|
@@ -59,7 +92,7 @@ Tuesday, December 22, 2020
|
|
59
92
|
* Lower the default target bitrates for 8-bit HEVC video in `other-transcode` to match the defaults for 10-bit HEVC video. This means, for example, the default target for HEVC at a 1080p resolution will be 6000 Kbps no matter the output bit depth.
|
60
93
|
* Modify `other-transcode` to set the video buffer size equal to the maximum video bitrate when using an Nvidia encoder, essentially adding `--rc-bufsize 3` to the command line. Previously the buffer size was never explicitly set so `ffmpeg` would use a default value of twice the target bitrate. Since the maximum bitrate is normally three times the target bitrate this meant the buffer size was actually smaller than the maximum. While this didn't cause any known problems, Nvidia recommends a larger buffer size to improve quality. However, using `--rc-bufsize 0` will restore the old behavior and the default value from `ffmpeg`.
|
61
94
|
* Ignore the `--nvenc-lookahead` option in `other-transcode` when the argument is `0` since such a value won't change the behavior of an Nvidia encoder anyway.
|
62
|
-
* Add a `--limit-ac3-surround` option to `other-transcode` which prevents surround audio in AC-3 or Dolby Digital Plus (Enhanced AC-3) format from being copied instead of transcoded when the orginal bitrate is above the transcoding bitrate. This allows setting a lower target with the `--surround-bitrate` option in order to force higher-bitrate tracks to be transcoded instead of copied.
|
95
|
+
* Add a `--limit-ac3-surround` option to `other-transcode` which prevents surround audio in AC-3 or Dolby Digital Plus (Enhanced AC-3) format from being copied instead of transcoded when the orginal bitrate is above the transcoding bitrate. This allows setting a lower target with the `--surround-bitrate` option in order to force higher-bitrate tracks to be transcoded instead of copied.
|
63
96
|
* Reduce the minimum bitrates for Dolby Digital Plus audio in `other-transcode` from 256, 128 and 64 Kbps for surround, stereo and mono layouts to 192, 96 and 48 Kbps. The default bitrates for Dolby Digital Plus audio remain the same and this change does not affect audio output in AC-3 or AAC formats.
|
64
97
|
|
65
98
|
## [0.5.0](https://github.com/donmelton/other_video_transcoding/releases/tag/0.5.0)
|
data/bin/ask-ffmpeg-log
CHANGED
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.9.0
|
22
22
|
Copyright (c) 2019-2021 Don Melton
|
23
23
|
HERE
|
24
24
|
end
|
@@ -139,15 +139,21 @@ Video options:
|
|
139
139
|
<<-HERE
|
140
140
|
--yadif-params KEY=VALUE[:KEY=VALUE]...
|
141
141
|
override yadif deinterlace filter configuration
|
142
|
-
--rc-maxrate FACTOR, --rc-bufsize FACTOR
|
142
|
+
--rc-maxrate FACTOR, --rc-bufsize FACTOR|BITRATE
|
143
143
|
set ratecontrol maximum rate and/or buffer size
|
144
|
-
as multiple of video bitrate target
|
144
|
+
as multiple of video bitrate target or specific bitrate
|
145
145
|
--copy-video disable transcoding and copy original video track
|
146
146
|
|
147
147
|
Apple Video Toolbox encoder options:
|
148
148
|
--vt-allow-sw allow software encoding
|
149
149
|
|
150
150
|
Nvidia video encoder options:
|
151
|
+
--nvenc-recommended
|
152
|
+
apply optimal quality settings, equivalent to using:
|
153
|
+
`--nvenc-spatial-aq`
|
154
|
+
`--nvenc-lookahead 32`
|
155
|
+
`--nvenc-bframe-refs middle`
|
156
|
+
(not supported on all Nvidia hardware)
|
151
157
|
--nvenc-spatial-aq
|
152
158
|
enable spatial adaptive quantization (AQ)
|
153
159
|
--nvenc-temporal-aq
|
@@ -160,8 +166,10 @@ Nvidia video encoder options:
|
|
160
166
|
set number of reference frames
|
161
167
|
--nvenc-bframes FRAMES
|
162
168
|
set maximum number of B-frames
|
163
|
-
--nvenc-
|
164
|
-
set
|
169
|
+
--nvenc-bframe-refs each|middle
|
170
|
+
set mode for using B-frames as reference frames
|
171
|
+
--nvenc-cq QUALITY
|
172
|
+
use constant quality (CQ) ratecontrol at target quality
|
165
173
|
|
166
174
|
Intel Quick Sync video encoder options:
|
167
175
|
--qsv-refs FRAMES
|
@@ -241,35 +249,39 @@ Audio options:
|
|
241
249
|
def usage15
|
242
250
|
<<-HERE
|
243
251
|
--surround-bitrate BITRATE
|
244
|
-
set surround audio bitrate (default:
|
252
|
+
set surround audio bitrate (default: 448)
|
245
253
|
--stereo-bitrate BITRATE
|
246
|
-
set stereo audio bitrate (default:
|
254
|
+
set stereo audio bitrate (default: 128)
|
247
255
|
HERE
|
248
256
|
end
|
249
257
|
|
250
258
|
def usage16
|
251
259
|
<<-HERE
|
252
260
|
--mono-bitrate BITRATE
|
253
|
-
set mono audio bitrate (default: 50% of stereo bitrate)
|
261
|
+
set mono audio bitrate (default: ~50% of stereo bitrate)
|
254
262
|
HERE
|
255
263
|
end
|
256
264
|
|
257
265
|
def usage17
|
258
266
|
<<-HERE
|
259
267
|
--eac3 use Dolby Digital Plus (E-AC-3) format for all audio
|
260
|
-
(default bitrates:
|
268
|
+
(default bitrates: 448 for surround, 192 for stereo)
|
261
269
|
HERE
|
262
270
|
end
|
263
271
|
|
264
272
|
def usage18
|
265
273
|
<<-HERE
|
266
|
-
--aac
|
274
|
+
--eac3-aac use Dolby Digital Plus format only for surround audio
|
275
|
+
with AAC format for stereo audio
|
276
|
+
--aac-only use AAC format for all audio,
|
277
|
+
disabling passthrough of audio in other formats
|
278
|
+
(default bitrates: 341 for surround, 128 for stereo)
|
267
279
|
--limit-ac3-surround
|
268
280
|
don't copy surround audio in AC-3 format
|
269
|
-
when orginal bitrate is above
|
281
|
+
when orginal bitrate is above passthrough bitrate
|
270
282
|
--keep-ac3-stereo
|
271
283
|
copy stereo and mono audio in AC-3 format
|
272
|
-
even when orginal bitrate is above
|
284
|
+
even when orginal bitrate is above passthrough bitrate
|
273
285
|
--pass-dts enable passthrough of audio in DTS and DTS-ES formats
|
274
286
|
HERE
|
275
287
|
end
|
@@ -311,7 +323,6 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
311
323
|
@detect = false
|
312
324
|
@preview = false
|
313
325
|
@format = :mkv
|
314
|
-
@mkv_options = []
|
315
326
|
@copy_track_names = false
|
316
327
|
@max_muxing_queue_size = nil
|
317
328
|
@dry_run = false
|
@@ -345,7 +356,8 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
345
356
|
@nvenc_multipass = nil
|
346
357
|
@nvenc_refs = nil
|
347
358
|
@nvenc_bframes = nil
|
348
|
-
@
|
359
|
+
@nvenc_bframe_refs = nil
|
360
|
+
@nvenc_cq = nil
|
349
361
|
@qsv_refs = nil
|
350
362
|
@qsv_bframes = nil
|
351
363
|
@amf_quality = nil
|
@@ -370,6 +382,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
370
382
|
@mono_bitrate = nil
|
371
383
|
@surround_encoder = 'ac3'
|
372
384
|
@stereo_encoder = nil
|
385
|
+
@aac_fallback_encoder = 'aac'
|
373
386
|
@keep_ac3_surround = true
|
374
387
|
@keep_ac3_stereo = false
|
375
388
|
@pass_dts = false
|
@@ -566,6 +579,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
566
579
|
@target = [arg.to_i, 1].max
|
567
580
|
end
|
568
581
|
|
582
|
+
@nvenc_cq = nil
|
569
583
|
@encoder = nil if @encoder == 'copy'
|
570
584
|
end
|
571
585
|
|
@@ -672,6 +686,13 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
672
686
|
@vt_allow_sw = true
|
673
687
|
end
|
674
688
|
|
689
|
+
opts.on '--nvenc-recommended' do
|
690
|
+
@encoder = @hevc ? 'hevc_nvenc' : 'h264_nvenc'
|
691
|
+
@nvenc_spatial_aq = true
|
692
|
+
@nvenc_lookahead = 32
|
693
|
+
@nvenc_bframe_refs = 'middle'
|
694
|
+
end
|
695
|
+
|
675
696
|
opts.on '--nvenc-spatial-aq' do
|
676
697
|
@encoder = @hevc ? 'hevc_nvenc' : 'h264_nvenc'
|
677
698
|
@nvenc_spatial_aq = true
|
@@ -713,17 +734,30 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
713
734
|
@nvenc_bframes = [[arg, 0].max, 4].min
|
714
735
|
end
|
715
736
|
|
716
|
-
opts.on '--nvenc-
|
737
|
+
opts.on '--nvenc-bframe-refs ARG' do |arg|
|
717
738
|
@encoder = @hevc ? 'hevc_nvenc' : 'h264_nvenc'
|
718
739
|
|
719
|
-
@
|
720
|
-
when '
|
740
|
+
@nvenc_bframe_refs = case arg
|
741
|
+
when 'each', 'middle'
|
721
742
|
arg
|
722
743
|
else
|
723
|
-
fail UsageError, "invalid
|
744
|
+
fail UsageError, "invalid B-frames as references argument: #{arg}"
|
724
745
|
end
|
725
746
|
end
|
726
747
|
|
748
|
+
opts.on '--nvenc-cq ARG', Float do |arg|
|
749
|
+
@encoder = @hevc ? 'hevc_nvenc' : 'h264_nvenc'
|
750
|
+
@nvenc_cq = [[arg, 1].max, 51].min.to_s.sub(/\.0$/, '')
|
751
|
+
end
|
752
|
+
|
753
|
+
opts.on '--nvenc-rc-mode ARG' do |arg|
|
754
|
+
Kernel.warn '**********'
|
755
|
+
Kernel.warn 'Using deprecated option: --nvenc-rc-mode'
|
756
|
+
Kernel.warn '**********'
|
757
|
+
@encoder = @hevc ? 'hevc_nvenc' : 'h264_nvenc'
|
758
|
+
fail UsageError, "invalid rate control argument: #{arg}" unless arg =~ /^vbr(_hq)?$/
|
759
|
+
end
|
760
|
+
|
727
761
|
opts.on '--qsv-refs ARG', Integer do |arg|
|
728
762
|
@encoder = @hevc ? 'hevc_qsv' : 'h264_qsv'
|
729
763
|
@qsv_refs = [arg, 0].max
|
@@ -860,6 +894,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
860
894
|
|
861
895
|
opts.on '--stereo-bitrate ARG', Integer do |arg|
|
862
896
|
@stereo_bitrate = arg
|
897
|
+
@mono_bitrate ||= @stereo_bitrate / 2
|
863
898
|
end
|
864
899
|
|
865
900
|
opts.on '--mono-bitrate ARG', Integer do |arg|
|
@@ -871,20 +906,35 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
871
906
|
@stereo_encoder = 'eac3'
|
872
907
|
end
|
873
908
|
|
909
|
+
opts.on '--eac3-aac' do
|
910
|
+
@surround_encoder = 'eac3'
|
911
|
+
@stereo_encoder = nil
|
912
|
+
end
|
913
|
+
|
874
914
|
opts.on '--aac-stereo' do
|
915
|
+
Kernel.warn '**********'
|
916
|
+
Kernel.warn 'Using deprecated option: --aac-stereo'
|
917
|
+
Kernel.warn '**********'
|
875
918
|
@stereo_encoder = nil
|
876
919
|
end
|
877
920
|
|
921
|
+
opts.on '--aac-only' do
|
922
|
+
@surround_encoder = nil
|
923
|
+
@stereo_encoder = nil
|
924
|
+
end
|
925
|
+
|
878
926
|
opts.on '--limit-ac3-surround' do
|
879
927
|
@keep_ac3_surround = false
|
880
928
|
end
|
881
929
|
|
882
930
|
opts.on '--keep-ac3-stereo' do
|
883
931
|
@keep_ac3_stereo = true
|
932
|
+
@surround_encoder ||= 'ac3'
|
884
933
|
end
|
885
934
|
|
886
935
|
opts.on '--pass-dts' do
|
887
936
|
@pass_dts = true
|
937
|
+
@surround_encoder ||= 'ac3'
|
888
938
|
end
|
889
939
|
|
890
940
|
opts.on '--add-subtitle ARG' do |arg|
|
@@ -938,32 +988,6 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
938
988
|
@audio_selections.uniq!
|
939
989
|
@subtitle_selections.uniq!
|
940
990
|
|
941
|
-
if @surround_encoder == 'eac3'
|
942
|
-
@surround_bitrate ||= 384
|
943
|
-
@surround_bitrate = [[@surround_bitrate, 192].max, 768].min
|
944
|
-
else
|
945
|
-
@surround_bitrate ||= 640
|
946
|
-
@surround_bitrate = [[@surround_bitrate, 256].max, 640].min
|
947
|
-
end
|
948
|
-
|
949
|
-
if @stereo_encoder == 'eac3'
|
950
|
-
@stereo_bitrate ||= 192
|
951
|
-
@stereo_bitrate = [[@stereo_bitrate, 96].max, 768].min
|
952
|
-
else
|
953
|
-
@stereo_bitrate ||= 256
|
954
|
-
@stereo_bitrate = [[@stereo_bitrate, 128].max, 320].min
|
955
|
-
end
|
956
|
-
|
957
|
-
if @mono_bitrate.nil?
|
958
|
-
@mono_bitrate = @stereo_bitrate / 2
|
959
|
-
else
|
960
|
-
if @stereo_encoder == 'eac3'
|
961
|
-
@mono_bitrate = [[@mono_bitrate, 48].max, 768].min
|
962
|
-
else
|
963
|
-
@mono_bitrate = [[@mono_bitrate, 64].max, 256].min
|
964
|
-
end
|
965
|
-
end
|
966
|
-
|
967
991
|
[
|
968
992
|
['ffprobe', '-loglevel', 'quiet', '-version'],
|
969
993
|
['ffmpeg', '-loglevel', 'quiet', '-version'],
|
@@ -1002,6 +1026,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1002
1026
|
end
|
1003
1027
|
end
|
1004
1028
|
|
1029
|
+
@nvenc_cq = nil unless @encoder =~ /nvenc$/
|
1005
1030
|
@ten_bit = (@hevc and @encoder =~ /(nvenc|qsv|x265)$/ ? true : false) if @ten_bit.nil?
|
1006
1031
|
@target_2160p ||= @hevc ? 8000 : 12000
|
1007
1032
|
@target_1080p ||= @hevc ? 4000 : 6000
|
@@ -1012,14 +1037,12 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1012
1037
|
if @stereo_encoder.nil?
|
1013
1038
|
if encoders =~ /aac_at/ or encoders =~ /libfdk_aac/
|
1014
1039
|
@stereo_encoder = $MATCH
|
1040
|
+
@aac_fallback_encoder = 'libfdk_aac' if encoders =~ /libfdk_aac/
|
1015
1041
|
else
|
1016
1042
|
@stereo_encoder = 'aac'
|
1017
1043
|
end
|
1018
|
-
end
|
1019
1044
|
|
1020
|
-
|
1021
|
-
capabilities = get_muxer_capabilities
|
1022
|
-
@mkv_options = ['-default_mode', 'passthrough'] if capabilities =~ /passthrough/
|
1045
|
+
@surround_encoder ||= @stereo_encoder
|
1023
1046
|
end
|
1024
1047
|
end
|
1025
1048
|
|
@@ -1069,17 +1092,17 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1069
1092
|
IO.popen([
|
1070
1093
|
'ffmpeg',
|
1071
1094
|
'-loglevel', 'quiet',
|
1072
|
-
'-nostdin'
|
1073
|
-
|
1095
|
+
'-nostdin',
|
1096
|
+
*(encoder =~ /vaapi$/ ? ['-vaapi_device', '/dev/dri/renderD128'] : []),
|
1074
1097
|
'-i', path,
|
1075
|
-
'-frames:v', '1'
|
1076
|
-
|
1098
|
+
'-frames:v', '1',
|
1099
|
+
*(encoder =~ /vaapi$/ ? ['-filter:v', 'format=nv12,hwupload'] : []),
|
1077
1100
|
'-c:v', encoder,
|
1078
|
-
'-b:v', '1000k'
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1101
|
+
'-b:v', '1000k',
|
1102
|
+
*(encoder =~ /nvenc$/ ? ['-rc:v', 'vbr'] : []),
|
1103
|
+
*(encoder == 'h264_qsv' ? ['-look_ahead:v', '1'] : []),
|
1104
|
+
*(encoder == 'hevc_qsv' ? ['-load_plugin:v', 'hevc_hw'] : []),
|
1105
|
+
*(encoder =~ /amf$/ ? ['-rc:v', 'vbr_latency'] : []),
|
1083
1106
|
'-an',
|
1084
1107
|
'-sn',
|
1085
1108
|
'-ignore_unknown',
|
@@ -1097,30 +1120,6 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1097
1120
|
$CHILD_STATUS.exitstatus == 0
|
1098
1121
|
end
|
1099
1122
|
|
1100
|
-
def get_muxer_capabilities
|
1101
|
-
Kernel.warn 'Getting muxer capabilities...'
|
1102
|
-
output = ''
|
1103
|
-
|
1104
|
-
begin
|
1105
|
-
IO.popen([
|
1106
|
-
'ffmpeg',
|
1107
|
-
'-loglevel', 'quiet',
|
1108
|
-
'-h', 'muxer=matroska'
|
1109
|
-
], :err=>[:child, :out]) do |io|
|
1110
|
-
io.each do |line|
|
1111
|
-
Kernel.warn line if @debug
|
1112
|
-
output += line
|
1113
|
-
end
|
1114
|
-
end
|
1115
|
-
rescue SystemCallError => e
|
1116
|
-
raise "getting muxer capabilities failed: #{e}"
|
1117
|
-
end
|
1118
|
-
|
1119
|
-
fail 'getting muxer capabilities failed' unless $CHILD_STATUS.exitstatus == 0
|
1120
|
-
|
1121
|
-
output
|
1122
|
-
end
|
1123
|
-
|
1124
1123
|
def process_input(path)
|
1125
1124
|
seconds = Time.now.tv_sec
|
1126
1125
|
|
@@ -1182,16 +1181,16 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1182
1181
|
ffmpeg_command = [
|
1183
1182
|
'ffmpeg',
|
1184
1183
|
'-loglevel', (@debug ? 'verbose' : 'error'),
|
1185
|
-
'-stats'
|
1186
|
-
|
1187
|
-
|
1188
|
-
'-i', path
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
'-metadata:g', 'title='
|
1194
|
-
|
1184
|
+
'-stats',
|
1185
|
+
*time_options,
|
1186
|
+
*decode_options,
|
1187
|
+
'-i', path,
|
1188
|
+
*(@max_muxing_queue_size.nil? ? [] : ['-max_muxing_queue_size', @max_muxing_queue_size.to_s]),
|
1189
|
+
*encode_options,
|
1190
|
+
*get_audio_options(media_info),
|
1191
|
+
*get_subtitle_options(media_info, burn_subtitle),
|
1192
|
+
'-metadata:g', 'title=',
|
1193
|
+
*(@format == :mkv ? ['-default_mode', 'passthrough'] : ['-movflags', 'disable_chpl']),
|
1195
1194
|
output_path
|
1196
1195
|
]
|
1197
1196
|
|
@@ -1351,10 +1350,11 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1351
1350
|
index += 1
|
1352
1351
|
puts "\##{index} subtitle:"
|
1353
1352
|
print " format = #{stream['codec_name']}"
|
1354
|
-
|
1353
|
+
tags = stream.fetch('tags', {})
|
1354
|
+
frames = tags.fetch('NUMBER_OF_FRAMES', tags.fetch('NUMBER_OF_FRAMES-eng', ''))
|
1355
1355
|
puts frames.empty? ? '' : " / #{frames} " + (frames == 1 ? 'frame' : 'frames')
|
1356
|
-
puts " language = #{
|
1357
|
-
title =
|
1356
|
+
puts " language = #{tags.fetch('language', '')}"
|
1357
|
+
title = tags.fetch('title', '')
|
1358
1358
|
puts " title = #{title}" unless title.empty?
|
1359
1359
|
default = (stream['disposition']['default'] == 1)
|
1360
1360
|
forced = (stream['disposition']['forced'] == 1)
|
@@ -1369,8 +1369,8 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1369
1369
|
end
|
1370
1370
|
|
1371
1371
|
def get_bitrate(stream)
|
1372
|
-
|
1373
|
-
bitrate = stream.fetch('tags',
|
1372
|
+
tags = stream.fetch('tags', {})
|
1373
|
+
bitrate = stream.fetch('bit_rate', tags.fetch('BPS', tags.fetch('BPS-eng', '')))
|
1374
1374
|
return nil if bitrate.empty?
|
1375
1375
|
|
1376
1376
|
bitrate.to_i / 1000
|
@@ -1632,12 +1632,6 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1632
1632
|
width = video['width'].to_i
|
1633
1633
|
height = video['height'].to_i
|
1634
1634
|
|
1635
|
-
if width == 720 and height == 576 and video['codec_name'] == 'mpeg2video'
|
1636
|
-
pal = true
|
1637
|
-
else
|
1638
|
-
pal = false
|
1639
|
-
end
|
1640
|
-
|
1641
1635
|
if crop.nil? or (crop == {:width => width, :height => height, :x => 0, :y => 0})
|
1642
1636
|
crop_filter = nil
|
1643
1637
|
else
|
@@ -1758,61 +1752,58 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1758
1752
|
]
|
1759
1753
|
end
|
1760
1754
|
|
1755
|
+
color_primaries = video['color_primaries']
|
1756
|
+
color_trc = video['color_transfer']
|
1757
|
+
colorspace = video['color_space']
|
1761
1758
|
ten_bit = (@ten_bit ? (@eight_bit_vc1 ? (video['codec_name'] != 'vc1') : true) : false)
|
1762
|
-
hdr = ((video.fetch('pix_fmt', 'yuv420p') == 'yuv420p10le') and ten_bit)
|
1763
1759
|
|
1764
|
-
if
|
1765
|
-
color_primaries
|
1766
|
-
color_trc
|
1767
|
-
colorspace
|
1768
|
-
else
|
1769
|
-
color_primaries = 'bt709'
|
1770
|
-
color_trc = 'bt709'
|
1771
|
-
colorspace = 'bt709'
|
1760
|
+
if (video.fetch('pix_fmt', 'yuv420p') == 'yuv420p10le') and ten_bit
|
1761
|
+
color_primaries ||= 'bt2020'
|
1762
|
+
color_trc ||= 'smpte2084'
|
1763
|
+
colorspace ||= 'bt2020nc'
|
1772
1764
|
end
|
1773
1765
|
|
1774
1766
|
if width > 1920 or height > 1080
|
1767
|
+
level = '5.1'
|
1775
1768
|
bitrate = @target_2160p
|
1776
|
-
max_bitrate =
|
1777
|
-
max_dpb_mbs = 184320
|
1769
|
+
max_bitrate = @hevc ? 25000 : 135000 # Level 5 HEVC Main 10 or H.264 Main
|
1778
1770
|
elsif width > 1280 or height > 720
|
1771
|
+
level = '4'
|
1779
1772
|
bitrate = @target_1080p
|
1780
|
-
max_bitrate = 20000
|
1781
|
-
max_dpb_mbs = 32768
|
1773
|
+
max_bitrate = @hevc ? 12000 : 20000 # Level 4
|
1782
1774
|
elsif width > 720 or height > 576
|
1775
|
+
level = '3.1'
|
1783
1776
|
bitrate = @target_720p
|
1784
|
-
max_bitrate = 10000
|
1785
|
-
max_dpb_mbs = 18000
|
1777
|
+
max_bitrate = @hevc ? 10000 : 14000 # Level 3.1
|
1786
1778
|
else
|
1779
|
+
color_primaries ||= (width == 720 and height == 576 and video['codec_name'] == 'mpeg2video') ? 'bt470bg' : 'smpte170m'
|
1780
|
+
colorspace ||= 'smpte170m'
|
1781
|
+
level = '3'
|
1787
1782
|
bitrate = @target_480p
|
1788
|
-
max_bitrate =
|
1789
|
-
max_dpb_mbs = 8100
|
1790
|
-
|
1791
|
-
unless hdr
|
1792
|
-
color_primaries = pal ? 'bt470bg' : 'smpte170m'
|
1793
|
-
colorspace = 'smpte170m'
|
1794
|
-
end
|
1783
|
+
max_bitrate = @hevc ? 6000 : 10000 # Level 3
|
1795
1784
|
end
|
1796
1785
|
|
1786
|
+
color_primaries ||= 'bt709'
|
1787
|
+
color_trc ||= 'bt709'
|
1788
|
+
colorspace ||= 'bt709'
|
1797
1789
|
bitrate = @target unless @target.nil?
|
1798
1790
|
bitrate = [bitrate, max_bitrate].min
|
1799
|
-
maxrate = 0
|
1800
|
-
bufsize = 0
|
1801
1791
|
|
1802
1792
|
if @encoder =~ /(nvenc|hevc_qsv|libx26[45])$/
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
maxrate = [[(bitrate * @maxrate).to_i,
|
1793
|
+
maxrate = [max_bitrate, bitrate * 2].max
|
1794
|
+
|
1795
|
+
unless @maxrate.nil?
|
1796
|
+
maxrate = [[(@maxrate < bitrate ? bitrate * @maxrate : @maxrate).to_i, bitrate].max, maxrate].min
|
1807
1797
|
end
|
1808
1798
|
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
bufsize = [[(bitrate * @bufsize).to_i, bitrate].max, bitrate * 4].min
|
1814
|
-
end
|
1799
|
+
bufsize = @encoder == 'hevc_qsv' ? 0 : maxrate
|
1800
|
+
|
1801
|
+
unless @bufsize.nil?
|
1802
|
+
bufsize = [[(@bufsize < bitrate ? bitrate * @bufsize : @bufsize).to_i, bitrate].max, maxrate].min
|
1815
1803
|
end
|
1804
|
+
else
|
1805
|
+
maxrate = 0
|
1806
|
+
bufsize = 0
|
1816
1807
|
end
|
1817
1808
|
|
1818
1809
|
unless @preset.nil?
|
@@ -1844,7 +1835,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1844
1835
|
text = "#{sprintf("%2d", video['index'])} = #{@encoder}"
|
1845
1836
|
|
1846
1837
|
unless @encoder == 'copy'
|
1847
|
-
text += " / #{bitrate} Kbps"
|
1838
|
+
text += @nvenc_cq.nil? ? " / #{bitrate} Kbps" : " / #{@nvenc_cq} CQ"
|
1848
1839
|
text += " / #{@preset}" unless @preset.nil?
|
1849
1840
|
end
|
1850
1841
|
|
@@ -1854,21 +1845,25 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1854
1845
|
|
1855
1846
|
Kernel.warn text
|
1856
1847
|
encode_options += ['-c:v', @encoder]
|
1857
|
-
encode_options += ['-pix_fmt:v', (@encoder =~ /(nvenc|qsv)$/ ? 'p010le' : 'yuv420p10le')] if ten_bit
|
1858
|
-
encode_options += ['-b:v', "#{bitrate}k"] unless @encoder == 'copy'
|
1848
|
+
encode_options += ['-pix_fmt:v', (@encoder =~ /(videotoolbox|nvenc|qsv)$/ ? 'p010le' : 'yuv420p10le')] if ten_bit
|
1849
|
+
encode_options += (@nvenc_cq.nil? ? ['-b:v', "#{bitrate}k"] : ['-cq:v', @nvenc_cq]) unless @encoder == 'copy'
|
1859
1850
|
encode_options += ['-maxrate:v', "#{maxrate}k"] if maxrate > 0
|
1860
1851
|
encode_options += ['-bufsize:v', "#{bufsize}k"] if bufsize > 0
|
1861
1852
|
encode_options += ['-preset:v', @preset] unless @preset.nil?
|
1862
|
-
|
1853
|
+
|
1854
|
+
if @encoder =~ /videotoolbox$/
|
1855
|
+
encode_options += ['-allow_sw:v', '1'] if @vt_allow_sw
|
1856
|
+
encode_options += ['-profile:v', 'main10'] if ten_bit
|
1857
|
+
end
|
1863
1858
|
|
1864
1859
|
if @encoder =~ /nvenc$/
|
1865
|
-
encode_options += ['-rc:v', @nvenc_rc_mode]
|
1866
1860
|
encode_options += ['-spatial-aq:v', '1'] if @nvenc_spatial_aq
|
1867
1861
|
encode_options += ['-temporal-aq:v', '1'] if @nvenc_temporal_aq
|
1868
1862
|
encode_options += ['-rc-lookahead:v', @nvenc_lookahead.to_s] unless @nvenc_lookahead.nil?
|
1869
1863
|
encode_options += ['-multipass:v', @nvenc_multipass] unless @nvenc_multipass.nil?
|
1870
1864
|
encode_options += ['-refs:v', @nvenc_refs.to_s] unless @nvenc_refs.nil?
|
1871
1865
|
encode_options += ['-bf:v', @nvenc_bframes.to_s] unless @nvenc_bframes.nil?
|
1866
|
+
encode_options += ['-b_ref_mode:v', @nvenc_bframe_refs] unless @nvenc_bframe_refs.nil?
|
1872
1867
|
end
|
1873
1868
|
|
1874
1869
|
if @encoder =~ /qsv$/
|
@@ -1904,20 +1899,10 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1904
1899
|
]
|
1905
1900
|
end
|
1906
1901
|
else
|
1907
|
-
max_refs = [(max_dpb_mbs / (((width + 15) / 16) * ((height + 15) / 16))), 16].min
|
1908
|
-
|
1909
1902
|
case @preset
|
1910
|
-
when 'slow'
|
1911
|
-
|
1912
|
-
when 'slower'
|
1913
|
-
refs = 8
|
1914
|
-
when 'veryslow', 'placebo'
|
1915
|
-
refs = 16
|
1916
|
-
else
|
1917
|
-
refs = 0
|
1903
|
+
when 'slow', 'slower', 'veryslow', 'placebo'
|
1904
|
+
encode_options += ['-level:v', level]
|
1918
1905
|
end
|
1919
|
-
|
1920
|
-
encode_options += ['-refs:v', max_refs.to_s] if refs > max_refs
|
1921
1906
|
end
|
1922
1907
|
|
1923
1908
|
encode_options += ['-x264-params:v', @x264_params] unless @x264_params.nil?
|
@@ -1970,15 +1955,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1970
1955
|
|
1971
1956
|
audio_tracks = [{
|
1972
1957
|
:stream => main_audio,
|
1973
|
-
:width => width
|
1974
|
-
:bitrate => case width
|
1975
|
-
when :stereo
|
1976
|
-
@stereo_bitrate
|
1977
|
-
when :surround
|
1978
|
-
@surround_bitrate
|
1979
|
-
when :original
|
1980
|
-
nil
|
1981
|
-
end
|
1958
|
+
:width => width
|
1982
1959
|
}]
|
1983
1960
|
|
1984
1961
|
titles = {}
|
@@ -1992,15 +1969,6 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
1992
1969
|
|
1993
1970
|
width = selection[:width]
|
1994
1971
|
|
1995
|
-
bitrate = case width
|
1996
|
-
when :stereo
|
1997
|
-
@stereo_bitrate
|
1998
|
-
when :surround
|
1999
|
-
@surround_bitrate
|
2000
|
-
when :original
|
2001
|
-
nil
|
2002
|
-
end
|
2003
|
-
|
2004
1972
|
unless selection[:track].nil?
|
2005
1973
|
audio_track = 0
|
2006
1974
|
|
@@ -2012,8 +1980,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
2012
1980
|
if audio_track == selection[:track]
|
2013
1981
|
audio_tracks += [{
|
2014
1982
|
:stream => stream,
|
2015
|
-
:width => width
|
2016
|
-
:bitrate => bitrate
|
1983
|
+
:width => width
|
2017
1984
|
}]
|
2018
1985
|
|
2019
1986
|
break
|
@@ -2030,8 +1997,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
2030
1997
|
stream['index'] != main_audio['index']
|
2031
1998
|
audio_tracks += [{
|
2032
1999
|
:stream => stream,
|
2033
|
-
:width => width
|
2034
|
-
:bitrate => bitrate
|
2000
|
+
:width => width
|
2035
2001
|
}]
|
2036
2002
|
end
|
2037
2003
|
end
|
@@ -2046,8 +2012,7 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
2046
2012
|
if title =~ /#{selection[:title]}/i and stream['index'] != main_audio['index']
|
2047
2013
|
audio_tracks += [{
|
2048
2014
|
:stream => stream,
|
2049
|
-
:width => width
|
2050
|
-
:bitrate => bitrate
|
2015
|
+
:width => width
|
2051
2016
|
}]
|
2052
2017
|
|
2053
2018
|
titles[stream['index']] = title
|
@@ -2073,23 +2038,32 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
2073
2038
|
if track[:width] == :original
|
2074
2039
|
encoder = 'copy'
|
2075
2040
|
else
|
2041
|
+
input_bitrate = track[:stream].fetch('bit_rate', '256').to_i / 1000
|
2076
2042
|
dts = (codec_name == 'dts' and track[:stream].fetch('profile', 'DTS') =~ /^DTS(?:-ES)?$/)
|
2077
2043
|
|
2078
2044
|
if track[:width] == :surround
|
2079
|
-
if (
|
2080
|
-
(@
|
2045
|
+
if (@surround_encoder =~ /aac/ and codec_name == 'aac') or
|
2046
|
+
(@surround_encoder =~ /ac3$/ and
|
2047
|
+
(codec_name == @surround_encoder or codec_name == 'ac3') and
|
2048
|
+
(@keep_ac3_surround or input_bitrate <= (@surround_bitrate.nil? ? 640 : @surround_bitrate))) or
|
2081
2049
|
(@pass_dts and dts)
|
2082
2050
|
encoder = 'copy'
|
2083
2051
|
elsif input_channels > 2
|
2084
2052
|
encoder = @surround_encoder
|
2085
2053
|
bitrate = @surround_bitrate
|
2054
|
+
|
2055
|
+
if encoder =~ /aac/
|
2056
|
+
encoder = @aac_fallback_encoder if encoder == 'aac_at'
|
2057
|
+
channels = 6
|
2058
|
+
end
|
2086
2059
|
end
|
2087
2060
|
end
|
2088
2061
|
|
2089
2062
|
if encoder.nil?
|
2090
2063
|
if input_channels <= 2 and (codec_name == 'aac' or
|
2091
|
-
(
|
2092
|
-
(@
|
2064
|
+
(@surround_encoder =~ /ac3$/ and
|
2065
|
+
(codec_name == @surround_encoder or codec_name == 'ac3') and
|
2066
|
+
(@keep_ac3_stereo or input_bitrate <= (@stereo_bitrate.nil? ? 256 : @stereo_bitrate))) or
|
2093
2067
|
(@pass_dts and dts))
|
2094
2068
|
encoder = 'copy'
|
2095
2069
|
else
|
@@ -2118,19 +2092,19 @@ Requires `ffprobe`, `ffmpeg` and `mkvpropedit`.
|
|
2118
2092
|
configurations[input_index] = configuration
|
2119
2093
|
text = "#{sprintf("%2d", input_index)} = #{encoder}"
|
2120
2094
|
text += " / #{bitrate} Kbps" unless bitrate.nil?
|
2121
|
-
text += ' / stereo' unless channels.nil?
|
2095
|
+
text += ' / stereo' unless channels.nil? or channels > 2
|
2122
2096
|
text += " / #{titles[input_index]}" if titles.has_key?(input_index)
|
2123
2097
|
Kernel.warn text
|
2124
2098
|
copy_track_name = (@copy_track_names or titles.has_key?(input_index))
|
2125
2099
|
|
2126
2100
|
options += [
|
2127
2101
|
'-map', "0:#{input_index}",
|
2128
|
-
"-c:a:#{index}", encoder
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2102
|
+
"-c:a:#{index}", encoder,
|
2103
|
+
*(encoder == 'aac_at' ? ["-aac_at_mode:a:#{index}", 'cvbr'] : []),
|
2104
|
+
*(bitrate.nil? ? [] : ["-b:a:#{index}", "#{bitrate}k"]),
|
2105
|
+
*(channels.nil? ? [] : ["-ac:a:#{index}", "#{channels}"]),
|
2106
|
+
*((encoder != 'copy' and track[:stream]['sample_rate'] != '48000') ? ["-ar:a:#{index}", '48000'] : []),
|
2107
|
+
*(copy_track_name ? [] : ["-metadata:s:a:#{index}", 'title=']),
|
2134
2108
|
"-disposition:a:#{index}", (index == 0 ? 'default' : '0')
|
2135
2109
|
]
|
2136
2110
|
|
Binary file
|
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.9.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: 2021-
|
11
|
+
date: 2021-06-05 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
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- other_video_transcoding-0.5.0.gem
|
36
36
|
- other_video_transcoding-0.6.0.gem
|
37
37
|
- other_video_transcoding-0.7.0.gem
|
38
|
+
- other_video_transcoding-0.8.0.gem
|
38
39
|
- other_video_transcoding.gemspec
|
39
40
|
homepage: https://github.com/donmelton/other_video_transcoding
|
40
41
|
licenses:
|