video_transcoding 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +37 -3
- data/bin/convert-video +1 -1
- data/bin/detect-crop +1 -1
- data/bin/query-handbrake-log +1 -1
- data/bin/transcode-video +55 -18
- data/lib/video_transcoding.rb +1 -1
- data/lib/video_transcoding/cli.rb +1 -1
- data/lib/video_transcoding/console.rb +1 -1
- data/lib/video_transcoding/copyright.rb +2 -2
- data/lib/video_transcoding/crop.rb +3 -1
- data/lib/video_transcoding/errors.rb +1 -1
- data/lib/video_transcoding/ffmpeg.rb +1 -1
- data/lib/video_transcoding/handbrake.rb +1 -1
- data/lib/video_transcoding/media.rb +1 -1
- data/lib/video_transcoding/mkvpropedit.rb +1 -1
- data/lib/video_transcoding/mp4track.rb +1 -1
- data/lib/video_transcoding/tool.rb +1 -1
- data/lib/video_transcoding/version.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03bf26235071514e773c623951ccf5363672daaaa6a47e382eb39047632a7535
|
4
|
+
data.tar.gz: 3c1e303d5002e0415a87ef397a17a08e4df547f8c3abcd3d5dd51bb8d4bfe2f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a309622bce60b49984c428fe261a19f0a6a43750b1f2e7cecb55f9d2f57d3c01947e45eb43024598ee19c0f1b677169dddfba9743f7b3024caf872204fd58ca
|
7
|
+
data.tar.gz: 98ca7b6d7827bc9361f3f6707f622138019f105eb9f67ab9132de7f218b775245c7b0052cfddc9a6f7a693c374deb56762e4c3d6680c82da64baa0f205a8de4d
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -563,7 +563,7 @@ These examples are written in Bash and only supply crop values. But almost any s
|
|
563
563
|
|
564
564
|
What is a ratecontrol system? It's how a video encoder decides on the amount of bits to allocate for a specific frame.
|
565
565
|
|
566
|
-
My `transcode-video` tool has
|
566
|
+
My `transcode-video` tool has four different ratecontrol systems which manipulate x264 and three which manipulate x265, both software-based video encoders built into `HandBrakeCLI`.
|
567
567
|
|
568
568
|
Additionally, `transcode-video` allows access to hardware-based video encoders which have their own ratecontrol systems.
|
569
569
|
|
@@ -603,6 +603,18 @@ It seems counterintuitive, but constraining the maximum bitrate prevents too muc
|
|
603
603
|
|
604
604
|
And this manipulation is exactly the same strategy used by streaming services such as Netflix.
|
605
605
|
|
606
|
+
### How my average variable bitrate (AVBR) ratecontrol system works
|
607
|
+
|
608
|
+
My average variable bitrate (AVBR) ratecontrol system, selected via the `--avbr` option, is also based on the ABR algorithm already within x264 which targets a specific bitrate.
|
609
|
+
|
610
|
+
But the maximum bitrate is not constrained like my ABR system.
|
611
|
+
|
612
|
+
Instead, the tolerance of missing the average bitrate is raised to the maximum amount, disabling overflow detection completely. This makes the ABR algorithm behave much more like a CRF-based encode, so final bitrates can be 10-15% higher or lower than the target.
|
613
|
+
|
614
|
+
And to prevent bitrates from getting too low, the Macroblock-tree ratecontrol system built into x264 is disabled. While this does lower compression efficiency somewhat, it significantly reduces blockiness, color banding and other artifacts.
|
615
|
+
|
616
|
+
Unfortunately, these modifications to implement AVBR are not possible when using x265.
|
617
|
+
|
606
618
|
## FAQ
|
607
619
|
|
608
620
|
### Should I worry about all these `VBV underflow` warnings?
|
@@ -629,9 +641,16 @@ While speed continues to improve, x265 is still considerably slower than the def
|
|
629
641
|
|
630
642
|
Hardware-based encoders, like those in [Intel Quick Sync Video](https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video), are often considerably faster than x264 or x265. Some are available in recent versions of HandBrake.
|
631
643
|
|
632
|
-
Check the output of `HandBrakeCLI --help` to find out if your platform has any of these video encoders available
|
644
|
+
Check the `Video Options` section from the output of `HandBrakeCLI --help` to find out if your platform has any of these video encoders available:
|
633
645
|
|
634
|
-
|
646
|
+
Platform | H.264 encoder | HEVC encoder
|
647
|
+
--- | --- | ---
|
648
|
+
Intel Quick Sync Video | `qsv_h264` | `qsv_h265` and `qsv_h265_10bit`
|
649
|
+
AMD Video Coding Engine | `vce_h264` | `vce_h265`
|
650
|
+
Nvidia NVENC | `nvenc_h264` | `nvenc_h265`
|
651
|
+
Apple VideoToolbox | `vt_h264` | `vt_h265`
|
652
|
+
|
653
|
+
You can try hardware-based transcoding now using the `--encoder` option. On macOS, select the Apple VideoToolbox H.264 encoder this way:
|
635
654
|
|
636
655
|
transcode-video --encoder vt_h264 "/path/to/Movie.mkv"
|
637
656
|
|
@@ -657,6 +676,21 @@ For a few problematic videos, I have to apply options like `--force-rate 23.976
|
|
657
676
|
|
658
677
|
## History
|
659
678
|
|
679
|
+
### [0.23.0](https://github.com/donmelton/video_transcoding/releases/tag/0.23.0)
|
680
|
+
|
681
|
+
Sunday, February 10, 2019
|
682
|
+
|
683
|
+
* Add a `--avbr` ratecontrol option to `transcode-video` (via [ #248](https://github.com/donmelton/video_transcoding/issues/248)) which:
|
684
|
+
* Implements an average variable bitrate (AVBR) ratecontrol system focused on maintaining quality at the risk of final bitrates being as much as 10-15% higher or lower than the target.
|
685
|
+
* May emit a few `VBV underflow` warnings at the beginning of a transcode, but nothing like the sustained deluge possible with my special, or default, ratecontrol system.
|
686
|
+
* Works only with the `x264` and `x264_10bit` encoders. Sorry, but the settings necessary to implement AVBR are not available with the `x265` family of encoders.
|
687
|
+
* Add my new AVBR ratecontrol system to the "Explanation" section of the "README" document.
|
688
|
+
* Add an undocumented `--raw` ratecontrol testing option to `transcode-video` which implements, by default, an unconstrained ABR system, easily modified with `--handbrake-option` and/or `--encoder-option`.
|
689
|
+
* Add a `--mixdown` option to `transcode-video` which sets the mixdown format for all AAC audio tracks, either Dolby Pro Logic II (the default) or stereo. Thanks to [@samhutchins](https://github.com/samhutchins) for the idea and the patch! Via [ #245](https://github.com/donmelton/video_transcoding/pull/245).
|
690
|
+
* Fix failure in `detect-crop` on Linux for certain inputs by forcing the text output from `ffmpeg` into UTF-8 binary format to ensure the correct parsing of that data during crop detection. Via [ #247](https://github.com/donmelton/video_transcoding/issues/247).
|
691
|
+
* List all hardware-based video encoders within the related answer in the "FAQ" section of the "README" document. Thanks to [@vr8hub](https://github.com/vr8hub) for the idea! Via [ #251](https://github.com/donmelton/video_transcoding/issues/251).
|
692
|
+
* Update all copyright notices to the year 2019.
|
693
|
+
|
660
694
|
### [0.22.0](https://github.com/donmelton/video_transcoding/releases/tag/0.22.0)
|
661
695
|
|
662
696
|
Saturday, December 15, 2018
|
data/bin/convert-video
CHANGED
data/bin/detect-crop
CHANGED
data/bin/query-handbrake-log
CHANGED
data/bin/transcode-video
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# transcode-video
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 Don Melton
|
6
6
|
#
|
7
7
|
|
8
8
|
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
@@ -62,6 +62,9 @@ Quality options:
|
|
62
62
|
(predictable size with different quality than default)
|
63
63
|
--simple use simple constrained ratecontrol
|
64
64
|
(limited size with different quality than default)
|
65
|
+
--avbr use average variable bitrate (AVBR) ratecontrol
|
66
|
+
(size near target with different quality than default)
|
67
|
+
(only available with x264 and x264_10bit encoders)
|
65
68
|
--target big|small
|
66
69
|
apply video bitrate target macro for all input resolutions
|
67
70
|
(`big` trades some size for increased quality)
|
@@ -154,6 +157,8 @@ Audio options:
|
|
154
157
|
(can be used multiple times)
|
155
158
|
--aac-encoder NAME
|
156
159
|
use named AAC audio encoder (default: platform dependent)
|
160
|
+
--mixdown dpl2|stereo
|
161
|
+
set mixdown format for stereo audio tracks (default: dpl2)
|
157
162
|
--no-audio disable all audio output
|
158
163
|
|
159
164
|
Subtitle options:
|
@@ -230,8 +235,7 @@ HERE
|
|
230
235
|
@format = :mkv
|
231
236
|
@log = true
|
232
237
|
@dry_run = false
|
233
|
-
@
|
234
|
-
@use_simple = false
|
238
|
+
@ratecontrol = :special
|
235
239
|
@target_bitrate_2160p = 12000
|
236
240
|
@target_bitrate_1080p = 6000
|
237
241
|
@target_bitrate_720p = 3000
|
@@ -256,6 +260,7 @@ HERE
|
|
256
260
|
@copy_audio = []
|
257
261
|
@copy_audio_name = []
|
258
262
|
@aac_encoder = nil
|
263
|
+
@mixdown = 'dpl2'
|
259
264
|
@burn_subtitle = nil
|
260
265
|
@force_subtitle = nil
|
261
266
|
@extra_subtitle = []
|
@@ -326,13 +331,19 @@ HERE
|
|
326
331
|
end
|
327
332
|
|
328
333
|
opts.on '--abr' do
|
329
|
-
@
|
330
|
-
@use_simple = false
|
334
|
+
@ratecontrol = :abr
|
331
335
|
end
|
332
336
|
|
333
337
|
opts.on '--simple' do
|
334
|
-
@
|
335
|
-
|
338
|
+
@ratecontrol = :simple
|
339
|
+
end
|
340
|
+
|
341
|
+
opts.on '--avbr' do
|
342
|
+
@ratecontrol = :avbr
|
343
|
+
end
|
344
|
+
|
345
|
+
opts.on '--raw' do
|
346
|
+
@ratecontrol = :raw
|
336
347
|
end
|
337
348
|
|
338
349
|
opts.on '--target ARG' do |arg|
|
@@ -607,6 +618,15 @@ HERE
|
|
607
618
|
end
|
608
619
|
end
|
609
620
|
|
621
|
+
opts.on '--mixdown ARG' do |arg|
|
622
|
+
@mixdown = case arg
|
623
|
+
when 'dpl2', 'stereo'
|
624
|
+
arg
|
625
|
+
else
|
626
|
+
fail UsageError, "invalid mixdown: #{arg}"
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
610
630
|
opts.on('--no-audio') { force_handbrake_option 'audio', 'none' }
|
611
631
|
|
612
632
|
opts.on '--burn-subtitle ARG' do |arg|
|
@@ -968,24 +988,41 @@ HERE
|
|
968
988
|
handbrake_options['encoder-level'] = encoder_level
|
969
989
|
end
|
970
990
|
|
971
|
-
|
991
|
+
signal_hrd = false
|
992
|
+
|
993
|
+
case @ratecontrol
|
994
|
+
when :special
|
995
|
+
handbrake_options['quality'] = '1'
|
996
|
+
encoder_options['vbv-maxrate'] = bitrate.to_s
|
997
|
+
encoder_options['vbv-bufsize'] = ((bitrate * 2).to_i).to_s
|
998
|
+
encoder_options['crf-max'] = '25'
|
999
|
+
encoder_options['qpmax'] = '34'
|
1000
|
+
when :abr
|
972
1001
|
handbrake_options['vb'] = bitrate.to_s
|
973
1002
|
encoder_options['vbv-maxrate'] = ((bitrate * 1.5).to_i).to_s
|
974
1003
|
encoder_options['vbv-bufsize'] = ((bitrate * 2).to_i).to_s
|
975
|
-
|
976
|
-
|
977
|
-
elsif @use_simple
|
1004
|
+
signal_hrd = true
|
1005
|
+
when :simple
|
978
1006
|
handbrake_options['quality'] = '1'
|
979
1007
|
encoder_options['vbv-maxrate'] = bitrate.to_s
|
980
1008
|
encoder_options['vbv-bufsize'] = bitrate.to_s
|
1009
|
+
signal_hrd = true
|
1010
|
+
when :avbr
|
1011
|
+
handbrake_options['vb'] = bitrate.to_s
|
1012
|
+
|
1013
|
+
if encoder =~ /^x264(?:_10bit)?$/
|
1014
|
+
encoder_options['ratetol'] = 'inf'
|
1015
|
+
encoder_options['mbtree'] = '0'
|
1016
|
+
else
|
1017
|
+
fail UsageError, "`--avbr` not available with the `#{encoder}` encoder"
|
1018
|
+
end
|
1019
|
+
when :raw
|
1020
|
+
handbrake_options['vb'] = bitrate.to_s unless @handbrake_options.has_key? 'quality'
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
if signal_hrd
|
981
1024
|
encoder_options['nal-hrd'] = 'vbr' if encoder =~ /^x264(?:_10bit)?$/
|
982
1025
|
encoder_options['hrd'] = '1' if encoder =~ /^x265(?:_1[02]bit)?$/
|
983
|
-
else
|
984
|
-
handbrake_options['quality'] = '1'
|
985
|
-
encoder_options['vbv-maxrate'] = bitrate.to_s
|
986
|
-
encoder_options['vbv-bufsize'] = ((bitrate * 2).to_i).to_s
|
987
|
-
encoder_options['crf-max'] = '25'
|
988
|
-
encoder_options['qpmax'] = '34'
|
989
1026
|
end
|
990
1027
|
|
991
1028
|
if (@quick or @veryquick) and
|
@@ -1088,7 +1125,7 @@ HERE
|
|
1088
1125
|
else
|
1089
1126
|
@aac_encoder ||= HandBrake.aac_encoder
|
1090
1127
|
encoders << @aac_encoder
|
1091
|
-
mixdowns << (info[:channels] > 2.0 ?
|
1128
|
+
mixdowns << (info[:channels] > 2.0 ? @mixdown : '')
|
1092
1129
|
end
|
1093
1130
|
|
1094
1131
|
bitrates << ''
|
data/lib/video_transcoding.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# crop.rb
|
3
3
|
#
|
4
|
-
# Copyright (c) 2013-
|
4
|
+
# Copyright (c) 2013-2019 Don Melton
|
5
5
|
#
|
6
6
|
|
7
7
|
module VideoTranscoding
|
@@ -51,6 +51,8 @@ module VideoTranscoding
|
|
51
51
|
last_seconds = seconds
|
52
52
|
end
|
53
53
|
|
54
|
+
line.encode! 'UTF-8', 'binary', invalid: :replace, undef: :replace, replace: ''
|
55
|
+
|
54
56
|
if line =~ / crop=([0-9]+):([0-9]+):([0-9]+):([0-9]+)$/
|
55
57
|
d_width, d_height, d_x, d_y = $1.to_i, $2.to_i, $3.to_i, $4.to_i
|
56
58
|
crop_width = d_width if crop_width < d_width
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video_transcoding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.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:
|
11
|
+
date: 2019-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Video Transcoding is a package of tools to transcode, inspect
|
@@ -63,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
|
67
|
-
rubygems_version: 2.7.7
|
66
|
+
rubygems_version: 3.0.2
|
68
67
|
signing_key:
|
69
68
|
specification_version: 4
|
70
69
|
summary: Tools to transcode, inspect and convert videos.
|