video_transcoding 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e3606bdc98fafac3af50e6871e4c8c1f0852e58
4
- data.tar.gz: e6db68299ae0058840579164d9cc53dd3f14e38c
3
+ metadata.gz: 63037b3fd63e5ef4cdf280232731e3872fd3b7da
4
+ data.tar.gz: 7d77a2257c90eaadfb4b8ef065bb57c977dee954
5
5
  SHA512:
6
- metadata.gz: 6625c65ce512c52d2e8891e6fe4aa95295f3ca421174e8de2f29abd63b85548cd0a62adb62b3deaa55d6145fdf24e8c0749b63c244efdcbb98384a14c7051fb7
7
- data.tar.gz: c6c84e5819aa65257b32728005c57bec07b8269f0832a37a14f839bec1570c82b096d1fe2e08bf5f73d5888852729dca5bde1347e47b193d8caf80ba2d220e88
6
+ metadata.gz: a949a564de75773a2b5a30f54b1bc388ad8065f46fe2b57ac24370644a58f44ac7a3a88e0ff5bf68920a274069ce575a57c9a71553910b121c96a2695b499819
7
+ data.tar.gz: 456fe2f3cef7e8cff23458348fd4f1292272682732ac6a636114e52fd33203fb766111f8c39b602db5b670e15d0aa6e1288fad1513c037b71f75612351d35072
data/README.md CHANGED
@@ -6,7 +6,7 @@ Tools to transcode, inspect and convert videos.
6
6
 
7
7
  Hi, I'm [Don Melton](http://donmelton.com/). I created these tools to transcode my collection of Blu-ray Discs and DVDs into a smaller, more portable format while remaining high enough quality to be mistaken for the originals.
8
8
 
9
- What makes these tools unique is the special rate control system which achieves those goals.
9
+ What makes these tools unique is the special ratecontrol system which achieves those goals.
10
10
 
11
11
  This package is based on my original collection of [Video Transcoding Scripts](https://github.com/donmelton/video-transcoding-scripts) written in Bash. While still available online, those scripts are no longer in active development. Users are encouraged to install this Ruby Gem instead.
12
12
 
@@ -31,13 +31,15 @@ Even if you don't try any of my tools, you may find this "README" document helpf
31
31
  * [Rationale](#rationale)
32
32
  * [Usage](#usage)
33
33
  * [Guide](#guide)
34
+ * [FAQ](#faq)
35
+ * [History](#history)
34
36
  * [Feedback](#feedback)
35
37
  * [Acknowledgements](#acknowledgements)
36
38
  * [License](#license)
37
39
 
38
40
  ## Installation
39
41
 
40
- My Video Transcoding tools are designed to work on OS X, Linux and Windows. They're packaged as a Gem and require Ruby version 2.0 or later. See "[Installing Ruby](https://www.ruby-lang.org/en/documentation/installation/)" if don't have the proper version on your platform.
42
+ My Video Transcoding tools are designed to work on OS X, Linux and Windows. They're packaged as a Gem and require Ruby version 2.0 or later. See "[Installing Ruby](https://www.ruby-lang.org/en/documentation/installation/)" if you don't have the proper version on your platform.
41
43
 
42
44
  Use this command to install the package:
43
45
 
@@ -47,6 +49,12 @@ You may need to prefix that command with `sudo` in some environments:
47
49
 
48
50
  sudo gem install video_transcoding
49
51
 
52
+ ### Updating
53
+
54
+ Use this command, or the variation prefixed with `sudo`, to update the package:
55
+
56
+ gem update video_transcoding
57
+
50
58
  ### Requirements
51
59
 
52
60
  Most of the tools in this package require other software to function properly, specifically these command line programs:
@@ -73,7 +81,7 @@ On OS X, the other dependencies can be easily installed via [Homebrew](http://br
73
81
 
74
82
  brew cask install handbrakecli
75
83
 
76
- On Linux, package management systems vary so it's best consult the indexes for those systems.
84
+ On Linux, package management systems vary so it's best consult the indexes for those systems. But there's a Homebrew port available called [Linuxbrew](http://linuxbrew.sh/) and it doesn't require root access.
77
85
 
78
86
  On Windows, it's best to search the Web for the appropriate binary or add-on package manager. The [VideoHelp](http://www.videohelp.com) and [Cygwin](https://cygwin.com/) sites are a good place to start.
79
87
 
@@ -89,7 +97,7 @@ HandBrake is a powerful video transcoding tool but it's complicated to configure
89
97
 
90
98
  HandBrake's "AppleTV 3" preset is closest to what I want but transcoding "[Planet Terror (2007)](http://www.blu-ray.com/movies/Planet-Terror-Blu-ray/1248/)" with it results in a huge video bitrate of 19.9 Mbps, very near the original of 22.9 Mbps. And transcoding "[The Girl with the Dragon Tattoo (2011)](http://www.blu-ray.com/movies/The-Girl-with-the-Dragon-Tattoo-Blu-ray/35744/)," while much smaller in output size, lacks detail compared to the original.
91
99
 
92
- So, the `transcode-video` tool configures the [x264 video encoder](http://www.videolan.org/developers/x264.html) within HandBrake to use a [constrained variable bitrate (CVBR)](https://en.wikipedia.org/wiki/Variable_bitrate) mode, and to automatically target bitrates appropriate for different input resolutions.
100
+ So, the `transcode-video` tool configures the [x264 video encoder](http://www.videolan.org/developers/x264.html) within HandBrake to use a modified [constrained variable bitrate (CVBR)](https://en.wikipedia.org/wiki/Variable_bitrate) mode, and to automatically target bitrates appropriate for different input resolutions.
93
101
 
94
102
  Input resolution | Target video bitrate
95
103
  --- | ---
@@ -344,6 +352,26 @@ Which prints out something like this:
344
352
 
345
353
  Just copy and paste the sample commands to preview or transcode.
346
354
 
355
+ If HandBrake and MPlayer disagree about the cropping values, then `detect-crop` prints out something like this:
356
+
357
+ Results differ...
358
+
359
+ # From HandBrakeCLI:
360
+
361
+ mplayer -really-quiet -nosound -vf rectangle=1920:816:0:132 '/path/to/Movie.mkv'
362
+ mplayer -really-quiet -nosound -vf crop=1920:816:0:132 '/path/to/Movie.mkv'
363
+
364
+ transcode-video --crop 132:132:0:0 '/path/to/Movie.mkv'
365
+
366
+ # From mplayer:
367
+
368
+ mplayer -really-quiet -nosound -vf rectangle=1920:820:0:130 '/path/to/Movie.mkv'
369
+ mplayer -really-quiet -nosound -vf crop=1920:820:0:130 '/path/to/Movie.mkv'
370
+
371
+ transcode-video --crop 130:130:0:0 '/path/to/Movie.mkv'
372
+
373
+ You'll then need to preview both and decide which to use.
374
+
347
375
  When input is a disc image directory instead of a single file, the `detect-crop` tool doesn't use MPlayer, nor does it print out commands to preview the crop.
348
376
 
349
377
  Be aware that the algorithm to determine optimal shape always crops from the top and bottom or from the left and right, never from both axes.
@@ -437,9 +465,9 @@ I have four rules when preparing my own media for transcoding:
437
465
 
438
466
  * [DTS-HD Master Audio](https://en.wikipedia.org/wiki/DTS-HD_Master_Audio) is the most popular high definition, lossless audio format. It's used on more than 80% of all Blu-ray Discs.
439
467
 
440
- * HandBrake, FFmpeg, MPlayer and other Open Source software can't decode the lossless portion of a DTS-HD audio track. They're only able to extract the non-HD, lossy core which is in [DTS format](https://en.wikipedia.org/wiki/DTS_(sound_system)).
468
+ * Currently, HandBrake can't decode the lossless portion of a DTS-HD audio track. It's only able to extract the non-HD, lossy core which is in [DTS format](https://en.wikipedia.org/wiki/DTS_(sound_system)).
441
469
 
442
- * But MakeMKV can [decode DTS-HD with some help from additional software](http://www.makemkv.com/dtshd/) and convert it into FLAC format which can then be decoded by HandBrake and most other software. Once again, MakeMKV can only do this when it converts the video into a single `.mkv` file.
470
+ * But MakeMKV can decode DTS-HD and convert it into FLAC format which can then be decoded by HandBrake and most other software. Once again, MakeMKV can only do this when it converts the video into a single `.mkv` file.
443
471
 
444
472
  ### Understanding the x264 preset system
445
473
 
@@ -555,6 +583,245 @@ The path is first deleted from the `queue.txt` file and then passed as an argume
555
583
 
556
584
  These examples are written in Bash and only supply crop values. But almost any scripting language can be used and any option can be changed on a per input basis.
557
585
 
586
+ ## FAQ
587
+
588
+ ### Should I worry about all these `VBV underflow` warnings?
589
+
590
+ No, these warnings are simply a side effect of my special ratecontrol system. The x264 video encoder within HandBrake is just being overly chatty. Ignore it. Nothing is wrong with the output from `transcode-video`.
591
+
592
+ ### Can you make a GUI version of your tools?
593
+
594
+ My command line tools have the same behavior and scriptable interface across multiple platforms. Developing a GUI application with those requirements is not an investment that I want to make.
595
+
596
+ Plus, I wouldn't use a GUI for these tasks. And it's a bad idea to develop software that you won't use yourself.
597
+
598
+ ### When will you add support for H.265 video?
599
+
600
+ [High Efficiency Video Coding](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding) or H.265 is the likely successor to [H.264](https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC), which is the format currently output by `transcode-video`. HandBrake has supported H.265 ever since it included the [x265 video encoder](http://x265.org/).
601
+
602
+ While the x265 encoder can produce the same quality as the x264 encoder at a lower bitrate, it's considerably slower. So slow, in fact, as to not be practical for home transcoding.
603
+
604
+ More importantly, my default ratecontrol system can't be applied with the x265 encoder. That's because x265 doesn't allow access to `qpmax`, critical for maintaining quality in certain situations. There's a [bug open on x265](https://bitbucket.org/multicoreware/x265/issues/232/add-option-to-specify-qpmax) about this now. When that's fixed, I'll consider adding support.
605
+
606
+ ### What about hardware-based video transcoding?
607
+
608
+ Using hardware with [Intel Quick Sync Video](https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video) instead of software like x264 is certainly faster. HandBrake even supports that hardware on some platforms. However, my default ratecontrol system can't be applied to existing hardware encoders because they lack API to change the necessary settings.
609
+
610
+ Also, keep in mind that hardware encoders are typically designed for realtime video chat or other similar duties. To maintain that performance, they often take shortcuts with video quality like reducing reference frames, lowering subpixel motion estimation, etc. Such an approach is the equivalent of using the `veryfast` preset with a software encoder. That's fine for video chat but I wouldn't recommend it for transcoding your disc collection.
611
+
612
+ ### Can you add support for Enhanced AC-3 audio?
613
+
614
+ [Dolby Digital Plus](https://en.wikipedia.org/wiki/Dolby_Digital_Plus) or Enhanced AC-3 is a successor to the Dolby Digital AC-3 audio format. AC-3 is the format currently output by `transcode-video` when surround audio is used as input. As of this writing, HandBrake only supports Enhanced AC-3 in development builds.
615
+
616
+ The original AC-3 format is limited to 5.1 audio channels. This means that any 7.1 channel audio track, typically available on Blu-ray Discs, needs to be downmixed during transcoding. The advantage to Enhanced AC-3 is that it can support up to 13.1 audio channels, so no downmixing is necessary.
617
+
618
+ I'll consider adding support once Enhanced AC-3 is available in an official HandBrake release.
619
+
620
+ ### How do you assess video transcoding quality?
621
+
622
+ I compare by visual inspection. Always with the video in motion, never frame by frame. It's tedious but after years of practice I know which portions of which videos are problematic and difficult to transcode. And I look at those first.
623
+
624
+ In addition, I use the `query-handbrake-log` tool to report on `ratefactor`, the average P-frame quantizer, to get a relative quality assessment from the x264 encoder.
625
+
626
+ What I don't use are [peak signal-to-noise ratios](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio) or a [structural similarity index](https://en.wikipedia.org/wiki/Structural_similarity) in an attempt to objectively compare quality. Although both metrics are available to the x264 encoder, enabling either of them ironically disables key psychovisual optimizations that improve quality.
627
+
628
+ ### What options do you use with `transcode-video`?
629
+
630
+ I use the default settings. That's why they're the defaults.
631
+
632
+ Of course, I apply crop values as necessary. And I let `transcode-video` automatically burn any forced subtitles into the output video track when the "forced" flag is enabled in the original.
633
+
634
+ I never include separate subtitle tracks, but I do add audio commentary tracks.
635
+
636
+ For a few problematic videos, I have to apply options like `--force-rate 23.976 --filter detelecine`. But that's rare.
637
+
638
+ ## History
639
+
640
+ ### 0.8.0
641
+
642
+ Sunday, April 24, 2016
643
+
644
+ * Add a `--no-constrain-crop` option to `transcode-video`. This changes the behavior of `--crop detect` to mimic the `--no-constrain` option in the `detect-crop` tool.
645
+ * Add a `--fallback-crop` option to `transcode-video`. This selects fallback crop values, from HandBrake, MPlayer or no crop at all, if `--crop detect` fails. This makes the new `--no-constrain-crop` option more useful since failure is more likely without constraints. Via #56 from @cameronks.
646
+ * Add a `--aac-encoder` option to `transcode-video`. This gives Windows and Linux users access to the Fraunhofer FDK AAC encoder if it's compiled into their version of `HandBrakeCLI`. Via #35 from @cnrd.
647
+ * Allow a colon (":") instead of a just period (".") to separate the two numerical components of a stream identifier when parsing scan output from `HandBrakeCLI`. This ensures compatibility with different versions of libavcodec and should fix several mysterious bugs on some Linux configurations. Via #30 and #41 from @dgibbs64.
648
+ * Maintain 480p video bitrate targets in `transcode-video` when scaling down to 480p using `--max-width 854 --max-height 480`. Via #58 from @mschout.
649
+ * Remove the deprecated `--old-behavior` option in `transcode-video`.
650
+ * Clarify the purpose of `--abr` and `--vbr` in the `--help` output of `transcode-video`.
651
+ * Update the "README" document to:
652
+ * Add "FAQ" section. Via #26 from @reiesu and #59 from @dgibbs64.
653
+ * Add this "History" section.
654
+ * Spell "rate control" as one word, like a real transcoding geek.
655
+ * Insert a missing "you" in the first paragraph of the "Installation" section.
656
+ * Mention and link to Linuxbrew in the "Requirements" section.
657
+ * Describe the default ratecontrol system as a "modified constrained variable bitrate (CVBR) mode."
658
+ * Add example output when HandBrake and MPlayer disagree to the "Using `detect-crop`" section. Via #18 from @alanwsmith.
659
+ * Update the status of DTS-HD decoding for HandBrake and MakeMKV in the "Why convert lossless audio?" section.
660
+
661
+ ### 0.7.0
662
+
663
+ Thursday, April 7, 2016
664
+
665
+ * Once again, lower the video bitrate targets for 480p and 720p output in `transcode-video`. Note that 1080p and 2160p targets still remain unchanged.
666
+ * Update the "README" document to:
667
+ * Reflect changes to the 480p and 720p video bitrate targets.
668
+ * Revise description of and recommendation for the `--quick` option.
669
+ * Revise warnings about using slower x264 presets.
670
+ * Add a `--target` option to `transcode-video` allowing explicit control of the video bitrate target.
671
+ * Deprecate the `--old-behavior` option in `transcode-video`.
672
+ * Remove the deprecated `--big` option in `transcode-video`.
673
+ * Separate `--small` and `--small-video` in the `--help` output of `transcode-video`.
674
+
675
+ ### 0.6.0
676
+
677
+ Sunday, April 3, 2016
678
+
679
+ * Revise the default ratecontrol system and video bitrate targets in `transcode-video`:
680
+ * Raise the quality target by lowering the constant ratefactor (CRF) from `16` to `1`, the lowest lossy CRF value available with the x264 video encoder. This significantly improves video quality but also raises bitrates much closer to the targets, thereby increasing output file sizes for some inputs.
681
+ * Raise the quality limit by setting `qpmax`, the x264 quantizer maximum, to `34`. This prevents x264 from occasionally generating a single, but still noticeable, very low quality frame because the CRF value is set so low.
682
+ * Lower the video bitrate targets for 480p and 720p output to keep bitrates and file sizes closer to that produced by the old ratecontrol system. Note that 1080p and 2160p targets remain unchanged.
683
+ * Add an `--old-behavior` option to restore the old ratecontrol system and video bitrate targets for users not yet wanting to change over. This option is only temporary and will soon be deprecated and then removed.
684
+ * Update the "README" document to reflect changes to the 480p and 720p video bitrate targets.
685
+ * Remove an obsolete `brew install caskroom/cask/brew-cask` line from the "README" document. Via #54 from @timsutton.
686
+
687
+ ### 0.5.1
688
+
689
+ Thursday, February 25, 2016
690
+
691
+ * Don't fail if the `ffmpeg` version string can't be parsed. Via #43 from @rementis, @Lambdafive and @kford.
692
+ * Remove the deprecated `--cvbr` option in `transcode-video`.
693
+
694
+ ### 0.5.0
695
+
696
+ Thursday, January 14, 2016
697
+
698
+ * Raise the default video bitrate targets and AC-3 audio bitrate limits in `transcode-video`:
699
+ * Deprecate the `--big` option since its behavior is now the default. An informal survey via Twitter and Facebook showed that about 90% of users (including myself) responding were always using the `--big` option anyway to get higher quality.
700
+ * Add a `--small` option to restore the old video bitrate targets and AC-3 audio bitrate limits.
701
+ * Add a `--small-video` option to restore only the old video bitrate targets. Via Facebook from @DaveHamilton.
702
+ * Update the "README" document to reflect all these changes.
703
+ * Move `--abr` and `--vbr` to the advanced options section in the `--help` output of `transcode-video`.
704
+ * Deprecate the experimental `--cvbr` option in `transcode-video`.
705
+
706
+ ### 0.4.0
707
+
708
+ Monday, January 1, 2016
709
+
710
+ * Add a `--cvbr` option to `transcode-video`. This implements a very experimental variation of the default ratecontrol system with a target bitrate as its single argument. Use it for evaluation purposes only.
711
+
712
+ ### 0.3.1
713
+
714
+ Friday, January 8, 2016
715
+
716
+ * Fix compatibility with development/nightly builds of `HandBrakeCL` in `transcode-video`:
717
+ * Always force the x264 `medium` preset to override the new `veryfast` default value. Via #36 from @cnrd.
718
+ * Explicitly set the encoder profile to `high` to override the new `main` default value.
719
+ * Explicitly (and dynamically) set the encoder level to override the new `4.0` default value.
720
+ * Fix a stupid regression from version 0.2.8 caused by a typo in the patch for the SubRip-format text file offset fix to `transcode-video`. Via #37 from @bpharriss.
721
+ * Be more lenient about `--encoder-option` arguments in `transcode-video` so `8x8dct` is allowed.
722
+ * Always print the `HandBrakeCLI` version string to diagnostic output even if it can't be parsed.
723
+
724
+ ### 0.3.0
725
+
726
+ Tuesday, January 5, 2016
727
+
728
+ * Add a `--abr` option to `transcode-video`. This implements a modified average bitrate (ABR) ratecontrol system with a target bitrate as its single argument. It produces a much more predictable output size but lower quality than the default ratecontrol system. It can sometimes be handy but use it with caution.
729
+ * Add a `--vbr` option to `transcode-video`. This implements a true VBR ratecontrol system with a constant ratefactor as its single argument, much like HandBrake's default behavior when using its `--quality` option. It's useful mostly for comparison testing against the default ratecontrol system.
730
+ * Update all copyright notices to the year 2016.
731
+
732
+ ### 0.2.8
733
+
734
+ Tuesday, January 5, 2016
735
+
736
+ * Prevent the `--bind-srt-language` option in `transcode-video` from also setting the SubRip-format text file offset to the same value. This was a stupid copy and paste error since the initial project version. Via #25 from @arikalish.
737
+ * Don't fail if the `HandBrakeCLI` version string can't be parsed. Via #29 from @paulbailey.
738
+ * Don't fail if the `mp4track` version string can't be parsed. Via #27 from @dgibbs64.
739
+ * Add a missing preposition to the last bullet point of the "Why MakeMKV?" section in the "README" document. Via #32 from @eventualbuddha.
740
+
741
+ ### 0.2.7
742
+
743
+ Tuesday, July 7, 2015
744
+
745
+ * Apply the `--subtitle-forced` option when scanning subtitles in `transcode-video`. Via #20 from @rhapsodians.
746
+
747
+ ### 0.2.6
748
+
749
+ Wednesday, May 20, 2015
750
+
751
+ * Prevent the user's file format choice from corrupting the output path in `transcode-video` and `convert-video`. Via #5 from @arikalish.
752
+
753
+ ### 0.2.5
754
+
755
+ Sunday, May 17, 2015
756
+
757
+ * Simplify the calculation of `vbv-bufsize` in `transcode-video`.
758
+
759
+ ### 0.2.4
760
+
761
+ Friday, May 15, 2015
762
+
763
+ * Prevent an undefined method error if `HandBrakeCLI` removes tracks during scan. Via #15 from @blackoctopus.
764
+
765
+ ### 0.2.3
766
+
767
+ Tuesday, May 12, 2015
768
+
769
+ * No longer fail on invalid audio and subtitle track information when parsing scan output from `HandBrakeCLI`. Via #11 from @eltito51 and #13 from @tchjunky.
770
+
771
+ ### 0.2.2
772
+
773
+ Monday, May 11, 2015
774
+
775
+ * Ensure the AC-3 passthru bitrate in `transcode-video` is never below the AC-3 encoding bitrate.
776
+
777
+ ### 0.2.1
778
+
779
+ Sunday, May 10, 2015
780
+
781
+ * Fix the `--main-audio` option in `transcode-video` by ensuring the `resolve_main_audio` method actually returns a result. Via #9 from @JMoVS.
782
+
783
+ ### 0.2.0
784
+
785
+ Saturday, May 9, 2015
786
+
787
+ * Rewrite the automatic frame rate and deinterlace logic in `transcode-video` to match the behavior of the old `transcode-video.sh` script on which the tool is based.
788
+ * Clarify in `--help` output that `transcode-video` audio copy policies only apply to main and explicitly added audio tracks.
789
+ * Ignore the sometimes missing patch version when checking MPlayer.
790
+ * Mention in the "README" document that custom track names and external subtitle file names are allowed to contain commas.
791
+
792
+ ### 0.1.4
793
+
794
+ Friday, May 8, 2015
795
+
796
+ * Fix a stupid regression from version 0.1.2 caused by the line endings fix on Windows. Via #7 from @brandonedling.
797
+
798
+ ### 0.1.3
799
+
800
+ Friday, May 8, 2015
801
+
802
+ * Check the extra version number for MPlayer to accept all builds. Via #6 from @CallumKerrEdwards.
803
+
804
+ ### 0.1.2
805
+
806
+ Thursday, May 7, 2015
807
+
808
+ * Fix handling of DOS-style line endings when parsing scan output from `HandBrakeCLI` on Windows. Via #4 from @CallumKerrEdwards and @commandtab.
809
+ * Disable automatic subtitle burning in `transcode-video` when input is MP4 format.
810
+ * Clarify usage of `--copy-audio` option in the "README" document.
811
+ * Fix some section links in the "README" document. Via #3 from @vitorgalvao.
812
+
813
+ ### 0.1.1
814
+
815
+ Wednesday, May 6, 2015
816
+
817
+ * Add a workaround in the `Media` class `initialize` method for no required keyword arguments in Ruby 2.0. Via #1 from @cadonau and #2 from @CallumKerrEdwards.
818
+
819
+ ### 0.1.0
820
+
821
+ Tuesday, May 5, 2015
822
+
823
+ * Initial project version.
824
+
558
825
  ## Feedback
559
826
 
560
827
  The best way to send feedback is mentioning me, [@donmelton](https://twitter.com/donmelton), on Twitter. You can also file bugs or ask questions in a longer form by [creating a new issue](https://github.com/donmelton/video_transcoding/issues) on GitHub. I always try to respond quickly but sometimes it may take as long as 24 hours.
data/bin/transcode-video CHANGED
@@ -69,6 +69,10 @@ Video options:
69
69
  --crop T:B:L:R set video crop values (default: 0:0:0:0)
70
70
  (use `--crop detect` for optimal crop values)
71
71
  (use `--crop auto` for `HandBrakeCLI` behavior)
72
+ --no-constrain-crop
73
+ don't constrain `--crop detect` to optimal shape
74
+ --fallback-crop handbrake|mplayer|none
75
+ select fallback crop values if `--crop detect` fails
72
76
  --720p fit video within 1280x720 pixel bounds
73
77
  --max-width WIDTH, --max-height HEIGHT
74
78
  fit video within horizontal and/or vertical pixel bounds
@@ -127,6 +131,8 @@ Audio options:
127
131
  or try to copy all track names in same manner
128
132
  (only applies to main and explicitly added audio tracks)
129
133
  (can be used multiple times)
134
+ --aac-encoder NAME
135
+ use named AAC audio encoder (default: platform dependent)
130
136
  --no-audio disable all audio output
131
137
 
132
138
  Subtitle options:
@@ -169,7 +175,9 @@ External subtitle options:
169
175
 
170
176
  Advanced options:
171
177
  --abr BITRATE use modified ABR ratecontrol at average video bitrate
178
+ (more predictable size but lower quality than default)
172
179
  --vbr QUALITY use true VBR ratecontrol at constant video quality (0-51)
180
+ (unpredictable size but useful for comparison to default)
173
181
  -E, --encoder-option NAME=VALUE|_NAME
174
182
  pass x264 video encoder option by name with value
175
183
  or disable use of option by prefixing name with "_"
@@ -212,6 +220,8 @@ HERE
212
220
  @vbv_maxrate_480p = 2000
213
221
  @quick = false
214
222
  @crop = {:top => 0, :bottom => 0, :left => 0, :right => 0}
223
+ @constrain_crop = true
224
+ @fallback_crop = nil
215
225
  @target_bitrate = nil
216
226
  @main_audio = nil
217
227
  @extra_audio = []
@@ -222,6 +232,7 @@ HERE
222
232
  @pass_ac3_bitrate = 640
223
233
  @copy_audio = []
224
234
  @copy_audio_name = []
235
+ @aac_encoder = nil
225
236
  @burn_subtitle = nil
226
237
  @force_subtitle = nil
227
238
  @extra_subtitle = []
@@ -233,7 +244,6 @@ HERE
233
244
  @srt_language = {}
234
245
  @srt_encoding = {}
235
246
  @srt_offset = {}
236
- @old_behavior = false
237
247
  @abr_bitrate = nil
238
248
  @vbr_quality = nil
239
249
  @encoder_options = {}
@@ -293,8 +303,8 @@ HERE
293
303
  opts.on '--small' do
294
304
  @vbv_maxrate_2160p = 10000
295
305
  @vbv_maxrate_1080p = 5000
296
- @vbv_maxrate_720p = @old_behavior ? 4000 : 3000
297
- @vbv_maxrate_480p = @old_behavior ? 2000 : 1600
306
+ @vbv_maxrate_720p = 3000
307
+ @vbv_maxrate_480p = 1600
298
308
  @ac3_bitrate = 384
299
309
  @pass_ac3_bitrate = 448
300
310
  end
@@ -302,8 +312,8 @@ HERE
302
312
  opts.on '--small-video' do
303
313
  @vbv_maxrate_2160p = 10000
304
314
  @vbv_maxrate_1080p = 5000
305
- @vbv_maxrate_720p = @old_behavior ? 4000 : 3000
306
- @vbv_maxrate_480p = @old_behavior ? 2000 : 1600
315
+ @vbv_maxrate_720p = 3000
316
+ @vbv_maxrate_480p = 1600
307
317
  end
308
318
 
309
319
  opts.on '--quick' do
@@ -336,6 +346,19 @@ HERE
336
346
  end
337
347
  end
338
348
 
349
+ opts.on '--no-constrain-crop' do
350
+ @constrain_crop = false
351
+ end
352
+
353
+ opts.on '--fallback-crop ARG' do |arg|
354
+ @fallback_crop = case arg
355
+ when 'handbrake', 'mplayer', 'none'
356
+ arg.to_sym
357
+ else
358
+ fail UsageError, "invalid fallback crop argument: #{arg}"
359
+ end
360
+ end
361
+
339
362
  opts.on '--720p' do
340
363
  force_handbrake_option 'maxWidth', '1280'
341
364
  force_handbrake_option 'maxHeight', '720'
@@ -491,6 +514,14 @@ HERE
491
514
  end
492
515
  end
493
516
 
517
+ opts.on '--aac-encoder ARG' do |arg|
518
+ if arg =~/_aac$/
519
+ @aac_encoder = arg
520
+ else
521
+ fail UsageError, "invalid aac encoder argument: #{arg}"
522
+ end
523
+ end
524
+
494
525
  opts.on('--no-audio') { force_handbrake_option 'audio', 'none' }
495
526
 
496
527
  opts.on '--burn-subtitle ARG' do |arg|
@@ -608,15 +639,6 @@ HERE
608
639
  @srt_offset[@srt_file.size - 1] = arg
609
640
  end
610
641
 
611
- opts.on '--old-behavior' do
612
- Console.warn 'Using deprecated option: --old-behavior'
613
- @old_behavior = true
614
- @vbv_maxrate_720p = 6000
615
- @vbv_maxrate_480p = 3000
616
- @abr_bitrate = nil
617
- @vbr_quality = nil
618
- end
619
-
620
642
  opts.on '--abr ARG', Integer do |arg|
621
643
  @abr_bitrate = arg
622
644
  @vbr_quality = nil
@@ -800,7 +822,7 @@ HERE
800
822
  elsif width > 1280 or height > 720
801
823
  handbrake_options['encoder-level'] = '4.0'
802
824
  vbv_maxrate = @vbv_maxrate_1080p
803
- elsif width > 720 or height > 576
825
+ elsif width * height > 720 * 576
804
826
  handbrake_options['encoder-level'] = '3.1'
805
827
  vbv_maxrate = @vbv_maxrate_720p
806
828
  else
@@ -816,7 +838,7 @@ HERE
816
838
  handbrake_options['encoder-level'] = 'auto'
817
839
  end
818
840
 
819
- handbrake_options['quality'] = @old_behavior ? '16' : '1'
841
+ handbrake_options['quality'] = '1'
820
842
 
821
843
  if @target_bitrate.nil?
822
844
  unless media.info[:directory]
@@ -845,7 +867,7 @@ HERE
845
867
  encoder_options['vbv-maxrate'] = vbv_maxrate.to_s
846
868
  encoder_options['vbv-bufsize'] = (@encoder_options.fetch('vbv-maxrate', vbv_maxrate).to_i / 2).to_s
847
869
  encoder_options['crf-max'] = '25'
848
- encoder_options['qpmax'] = '34' unless @old_behavior
870
+ encoder_options['qpmax'] = '34'
849
871
  else
850
872
  unless @abr_bitrate.nil?
851
873
  handbrake_options['vb'] = @abr_bitrate.to_s
@@ -892,21 +914,32 @@ HERE
892
914
  def resolve_crop(media)
893
915
  if @crop == :detect
894
916
  width, height = media.info[:width], media.info[:height]
895
- hb_crop = Crop.constrain(media.info[:autocrop], width, height)
917
+ hb_crop = media.info[:autocrop]
918
+ hb_crop = Crop.constrain(hb_crop, width, height) if @constrain_crop
919
+ crop = hb_crop
896
920
 
897
921
  unless media.info[:directory]
898
922
  mp_crop = Crop.detect(media.path, media.info[:duration], width, height)
899
- mp_crop = Crop.constrain(mp_crop, width, height)
923
+ mp_crop = Crop.constrain(mp_crop, width, height) if @constrain_crop
900
924
 
901
925
  if hb_crop != mp_crop
902
- Console.error 'Results differ...'
903
- Console.error "From HandBrakeCLI: #{Crop.handbrake_string(hb_crop)}"
904
- Console.error "From mplayer: #{Crop.handbrake_string(mp_crop)}"
905
- fail "crop detection failed: #{media.path}"
926
+ crop = case @fallback_crop
927
+ when :handbrake
928
+ hb_crop
929
+ when :mplayer
930
+ mp_crop
931
+ when :none
932
+ {:top => 0, :bottom => 0, :left => 0, :right => 0}
933
+ else
934
+ Console.error 'Results differ...'
935
+ Console.error "From HandBrakeCLI: #{Crop.handbrake_string(hb_crop)}"
936
+ Console.error "From mplayer: #{Crop.handbrake_string(mp_crop)}"
937
+ fail "crop detection failed: #{media.path}"
938
+ end
906
939
  end
907
940
  end
908
941
 
909
- hb_crop
942
+ crop
910
943
  elsif @crop == :auto
911
944
  nil
912
945
  else
@@ -958,7 +991,8 @@ HERE
958
991
  if copy or (info[:format] == 'AAC' and info[:channels] <= 2.0)
959
992
  encoders << 'copy'
960
993
  else
961
- encoders << HandBrake.aac_encoder
994
+ @aac_encoder ||= HandBrake.aac_encoder
995
+ encoders << @aac_encoder
962
996
  end
963
997
 
964
998
  bitrates << ''
@@ -135,7 +135,7 @@ module VideoTranscoding
135
135
  subtitle_track = 0
136
136
 
137
137
  @scan.each_line do |line|
138
- if line =~ /[ ]+Stream #0\.([0-9]+)[^ ]*: (Video|Audio|Subtitle): (.*)/
138
+ if line =~ /[ ]+Stream #0[.:]([0-9]+)[^ ]*: (Video|Audio|Subtitle): (.*)/
139
139
  stream = $1.to_i
140
140
  type = $2
141
141
  attributes = $3
@@ -164,7 +164,7 @@ module VideoTranscoding
164
164
  track_info[:default] = false
165
165
  end
166
166
 
167
- if @scan =~ /[ ]+Stream #0\.#{stream}[^ ]*: Audio: [^\n]+\n[ ]+Metadata:\r?\n^[ ]+title[ ]+: ([^\r\n]+)/m
167
+ if @scan =~ /[ ]+Stream #0[.:]#{stream}[^ ]*: Audio: [^\n]+\n[ ]+Metadata:\r?\n^[ ]+title[ ]+: ([^\r\n]+)/m
168
168
  track_info[:name] = $1
169
169
  else
170
170
  track_info[:name] = nil
@@ -189,7 +189,7 @@ module VideoTranscoding
189
189
  track_info[:forced] = false
190
190
  end
191
191
 
192
- if @scan =~ /[ ]+Stream #0\.#{stream}[^ ]*: Subtitle: [^\n]+\n[ ]+Metadata:\r?\n^[ ]+title[ ]+: ([^\r\n]+)/m
192
+ if @scan =~ /[ ]+Stream #0[.:]#{stream}[^ ]*: Subtitle: [^\n]+\n[ ]+Metadata:\r?\n^[ ]+title[ ]+: ([^\r\n]+)/m
193
193
  track_info[:name] = $1
194
194
  else
195
195
  track_info[:name] = nil
@@ -5,5 +5,5 @@
5
5
  #
6
6
 
7
7
  module VideoTranscoding
8
- VERSION = '0.7.0'
8
+ VERSION = '0.8.0'
9
9
  end
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.7.0
4
+ version: 0.8.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: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Video Transcoding is a package of tools to transcode, inspect