HandBrake: Difference between revisions

From miki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
* [https://handbrake.fr/docs/en/latest/technical/performance.html Handbrake -- Performance]
* [https://handbrake.fr/docs/en/latest/technical/performance.html Handbrake -- Performance]
* [https://handbrake.fr/docs/en/1.3.0/technical/anamorphic-guide.html Anamorphic guide (PAR, pixel aspect ratio...)]
* [https://handbrake.fr/docs/en/1.3.0/technical/anamorphic-guide.html Anamorphic guide (PAR, pixel aspect ratio...)]

;On this wiki
* [[Dv]] — capture and transcode of DV tapes.

== General ==
=== Configuration ===
* Config files are stored in {{file|~/.config/ghb}}
:* Other possible locations are {{file|~/.var/app/fr.handbrake.ghb}}.


== Tips ==
== Tips ==
Line 114: Line 122:
:* make sure there is no negative audio gain (note there is a bug in HB that by default set the gain to -20db). Better leave the gain at 0db.
:* make sure there is no negative audio gain (note there is a bug in HB that by default set the gain to -20db). Better leave the gain at 0db.
:* select same mixdown as source.
:* select same mixdown as source.

=== Video ===
;x265
* From tests, medium preset Q 20.00 encodes as fast as medium preset Q 19.00, but the latter produces bigger (better quality) video.

To try:
* x265 Q20.00 medium
* x265 Q19.00 medium
* x265 Q18.00 medium
* x265 Q18.00 slow


=== Video - aspect ratio ===
=== Video - aspect ratio ===
Line 237: Line 255:
:* Plex App on Shield: '''Direct AV''', 8s delay only. Also with External SRT.
:* Plex App on Shield: '''Direct AV''', 8s delay only. Also with External SRT.
:* Plex Kodi on Shield: '''Direct *Play* AV'''. 3s max delay.
:* Plex Kodi on Shield: '''Direct *Play* AV'''. 3s max delay.

=== Test summary ===
Using the script below.
* Filters are not shown (decomb or denoise may significantly change the FPS / BITRATE).

<pre>
PATH ENCODER LEVEL OPTIONS PRESET PROFILE QUALITY TUNE TURBO TWOPASS SIZE FPS BITRATE FPS BITRATE
"21_Grams" x264 3.1 "" fast main 20.0 "" false false 720x552 109.9 2195.60
"Abduction" x265 "" "" medium auto 20.0 "" false false 720x428 36.3 755.53
"Arthur_et_les_minimoys_2" x265 "" "" medium auto 20.0 "" false false 720x436 30.1 1228.08
"Arthur_et_les_minimoys_3" x265 "" "" medium auto 20.0 "" false false 720x438 29.2 1430.21
"Arthur_et_les_Minimoys" x265 "" "" medium auto 20.0 "" false false 720x432 36.4 1019.37
"Babel" x265 "" "" medium auto 20.0 "" false false 718x556 31.0 894.37
"Bad_Teacher" x264 3.1 "" fast main 20.0 "" false false 720x552 163.2 1151.62
"Bad_Teacher" x264 3.1 "" fast main 20.0 "" false false 720x552 163.8 1151.62
"Bad_Teacher" x264 3.1 "" fast main 20.0 "" false false 720x552 177.9 1151.63
"Bad_Teacher" x264 3.1 "" slower high 18.0 film true true 720x552 64.2 1456.83
"Bad_Teacher" x264 3.1 "" slow high 16.0 film true true 720x552 86.1 2077.35
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 81.9 1901.26
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 83.0 1726.80
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 88.7 1702.91
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 93.0 1536.69
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 93.2 1536.69
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 95.7 1672.58
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 96.9 1672.58
"Bad_Teacher" x264 3.1 "" slow high 18.0 film false false 720x552 97.3 1445.91
"Bad_Teacher" x264 3.1 "" slow high 19.0 film false false 720x552 99.5 1276.99
"Bad_Teacher" x264 3.1 "" slow high 20.0 film false false 720x552 106.6 1070.31
"Bad_Teacher" x264 3.1 "" slow high 20.0 film false false 720x552 107.6 1070.31
"Bad_Teacher" x264 3.1 "" slow high 20.0 film false false 720x552 108.4 1070.31
"Bad_Teacher" x264 3.1 "" slow high "" film false true 720x552 90.8 1780.17 95.9 1799.93
"Bad_Teacher" x264 3.1 "" slow high "" film true true 720x552 252.6 1781.79 97.8 1799.60
"Bad_Teacher" x264 4.0 "" veryfast main 20.0 "" false false 720x552 332.8 952.46
"Bad_Teacher" x264 4.0 "" veryfast main 22.0 "" false false 720x552 332.7 654.67
"Bad_Teacher" x264 4.0 "" veryfast main 22.0 "" false false 720x552 350.9 660.70
"Bad_Teacher" x265 auto "" medium auto 20.0 "" false false 720x552 39.9 778.46
"Bad_Teacher" x265 auto "" medium auto 20.0 "" false false 720x552 41.7 706.52
"Bad_Teacher" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 19.0 "" false false 720x552 41.1 789.73
"Bad_Teacher" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 20.0 "" false false 720x552 42.9 672.42
"Bad_Teacher" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 20.0 "" false false 720x552 43.2 672.42
"Bad_Teacher" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 slow main 20.0 "" false false 720x552 23.6 754.62
"Bad_Teacher" x265 auto threads=2 medium auto 20.0 "" false false 720x552 38.7 910.50
"Bad_Teacher" x265 auto :threads=2 medium auto 20.0 "" false false 720x552 46.8 627.42
"Beignets_de_Tomates_Vertes" x265 "" "" medium auto 20.0 "" false false 718x550 33.8 879.23
"Bienvenue_à_bord" x265 "" "" medium auto 20.0 "" false false 720x428 34.6 872.17
"Black_Swan" x265 "" "" medium auto 20.0 "" false false 720x428 37.6 829.10
"Brave" x264 3.1 "" slow high 18.0 film false false 720x428 92.3 1572.53
"Brave" x264 3.1 "" slow high 19.0 film false false 720x428 98.4 1342.36
"Brave" x264 3.1 "" slow high 20.0 film false false 720x428 102.6 1148.41
"Brave" x264 3.1 "" slow high 20.0 film false false 720x428 104.3 1148.41
"Brave" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 19.0 "" false false 720x428 38.8 873.15
"Brave" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 20.0 "" false false 720x428 40.5 754.75
"Brave" x265 "" "" medium auto 20.0 "" false false 720x428 34.6 779.28
"Brooklyn" x265 "" "" medium auto 20.0 "" false false 720x552 39.5 587.93
"Cars" x265 "" "" medium auto 20.0 "" false false 720x426 37.4 1258.09
"Cloverfield" x265 "" "" medium auto 20.0 "" false false 720x570 30.3 1039.41
"Crash" x265 "" "" medium auto 20.0 "" false false 702x572 34.2 683.68
"Crazy_Stupid_Love" x265 "" "" medium auto 20.0 "" false false 720x426 39.4 593.34
"Fanny" x265 "" "" medium auto 20.0 "" false false 720x552 36.3 857.03
"FINAL_CUT_1998_PAL_DVD5-mOe.iso" x264 3.1 "" slow high 18.0 film false false 720x576 73.5 3103.34
"FINAL_CUT_1998_PAL_DVD5-mOe.iso" x264 3.1 "" slow high 18.0 film false false 720x576 78.3 2734.55
"FINAL_CUT_1998_PAL_DVD5-mOe.iso" x264 3.1 "" slow high 20.0 film false false 720x576 89.0 1821.75
"FitnessExpander" x265 "" "" medium auto 20.0 "" false false 718x432 30.8 2089.19
"Ghost_in_a_Shell" x265 "" "" medium auto 20.0 "" false false 708x544 45.3 662.16
"Hanna" x264 3.1 "" fast main 20.0 "" false false 720x428 128.9 855.14
"Hanna" x265 "" "" medium auto 20.0 "" false false 720x428 41.4 536.65
"Hansel_and_Gretel_Witch_Hunters" x265 "" "" medium auto 20.0 "" false false 720x428 34.9 766.68
"Harold_and_Maude" x265 "" "" medium auto 20.0 "" false false 704x576 33.0 955.33
"Harry_Potter_5_Order_of_the_Phoenix" x264 3.1 "" fast main 20.0 "" false false 720x424 189.9 1067.77
"Harry_Potter_5_Order_of_the_Phoenix" x264 3.1 "" fast main 20.0 "" false false 720x424 190.6 1067.78
"Hotel_Transylvania" x265 "" "" medium auto 20.0 "" false false 720x552 34.1 828.61
"Howls_Moving_Castle" x265 "" "" medium auto 20.0 "" false false 720x552 41.9 1245.70
"Inspecteur_la_Bavure" x265 "" "" medium auto 20.0 "" false false 660x576 30.2 1169.45
"Interstellar" x264 3.1 "" slow high 18.0 film false false 720x428 99.2 1217.00
"Interstellar" x264 3.1 "" slow high 19.0 film false false 720x428 106.7 1031.81
"Interstellar" x264 3.1 "" slow high 20.0 film false false 720x428 112.7 880.15
"Interstellar" x264 3.1 "" slow high 20.0 film false false 720x428 114.3 880.15
"Interstellar" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 19.0 "" false false 720x428 41.9 680.24
"Interstellar" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 20.0 "" false false 720x428 43.9 586.21
"Interstellar" x265 "" "" medium auto 20.0 "" false false 720x428 37.6 605.70
"Joan_of_Arc_-_FR" x265 "" "" medium auto 20.0 "" false false 702x432 36.7 838.71
"Joan_of_Arc" x265 "" "" medium auto 20.0 "" false false 702x432 36.4 838.71
"La_Fée" x264 3.1 "" fast main 20.0 "" false false 718x576 138.9 985.62
"La_Fée" x264 3.1 "" fast main 20.0 "" false false 718x576 176.5 985.62
"La_Fille_du_Puisatier" x265 "" "" medium auto 20.0 "" false false 720x552 29.2 1499.65
"La_Moustache" x265 "" "" medium auto 20.0 "" false false 720x552 35.1 898.51
"La_Soupe_aux_Choux" x264 3.1 "" fast main 20.0 "" false false 720x436 139.6 1060.86
"La_Soupe_aux_Choux" x264 3.1 "" fast main 20.0 "" false false 720x436 185.8 1060.86
"Le_Baron_de_Munchausen" x264 3.1 "" fast main 20.0 "" false false 702x552 128.6 2006.41
"Le_Baron_de_Munchausen" x264 3.1 "" fast main 20.0 "" false false 702x552 144.3 2006.41
"L_ecume_des_Jours" x264 3.1 "" fast main 20.0 "" false false 720x554 184.0 1268.97
"Le_Gendarme_et_les_Extra-Terrestres" x264 3.1 "" fast main 20.0 "" false false 660x576 173.7 1862.95
"Le_Grand_Blond" x264 3.1 "" fast main 20.0 "" false false 678x576 197.4 1568.68
"Le_Retour_du_Grand_Blond" x264 3.1 "" fast main 20.0 "" false false 700x576 185.9 1592.53
"Les_Aventures_De_Rabbi_Jacob" x264 3.1 "" fast main 20.0 "" false false 678x576 149.1 2842.31
"Les_Aventures_du_Baron_Munchausen" x264 3.1 "" fast main 20.0 "" false false 702x552 151.3 2006.41
"Les_Comperes" x265 "" "" medium auto 20.0 "" false false 658x576 27.0 1647.45
"Les_Enfants_de_Timpelbach" x265 "" "" medium auto 20.0 "" false false 720x436 35.5 1102.33
"Les_Femmes_ou_les_Enfants_d_abord" x264 3.1 "" fast main 20.0 "" false false 702x432 111.3 1369.30
"Les_Femmes_ou_les_Enfants_d_abord" x264 3.1 "" fast main 20.0 "" false false 718x432 139.5 1256.70
"Les_Fugitifs" x265 "" "" medium auto 20.0 "" false false 656x576 30.3 1250.70
"Let_Me_In" x265 "" "" medium auto 20.0 "" false false 718x428 54.7 327.30
"Let_the_Right_One_In" x265 "" "" medium auto 20.0 "" false false 720x436 53.3 359.90
"Lucas_Fourmi_Malgre_Lui" x265 "" "" medium auto 20.0 "" false false 702x428 37.6 694.53
"Marius" x265 "" "" medium auto 20.0 "" false false 720x552 33.9 906.23
"Mission_Cleopatre" x265 "" "" medium auto 20.0 "" false false 716x432 33.7 905.42
"Populaire" x265 "" "" medium auto 20.0 "" false false 720x556 40.2 540.47
"Pretty_Woman" x265 "" "" medium auto 20.0 "" false false 706x542 40.2 748.25
"prometheus" x265 "" "" medium auto 20.0 "" false false 718x424 45.6 497.97
"Pulp_Fiction" x265 "" "" medium auto 20.0 "" false false 702x436 47.9 538.03
"Qu_est-ce_qu_on_a_fait_au_bon_dieu" x265 "" "" medium auto 20.0 "" false false 720x552 36.3 930.70
"Rio" x265 "" "" medium auto 20.0 "" false false 718x428 36.6 752.25
"RTT" x265 "" "" medium auto 20.0 "" false false 720x432 31.2 1144.21
"Serenity" x265 "" "" medium auto 20.0 "" false false 720x436 41.4 664.90
"Stand_by_Me" x265 "" "" medium auto 20.0 "" false false 702x550 35.5 1025.44
"The_Sister_Act_2" x265 "" "" medium auto 20.0 "" false false 718x576 36.4 835.03
"Thor_The_Dark_World" x264 3.1 "" slow high 18.0 film false false 720x428 101.1 1211.24
"Thor_The_Dark_World" x264 3.1 "" slow high 18.0 film false false 720x428 92.4 1666.77
"Thor_The_Dark_World" x264 3.1 "" slow high 19.0 film false false 720x428 107.6 1036.66
"Thor_The_Dark_World" x264 3.1 "" slow high 19.0 film false false 720x428 95.2 1437.17
"Thor_The_Dark_World" x264 3.1 "" slow high 20.0 film false false 720x428 100.8 1241.99
"Thor_The_Dark_World" x264 3.1 "" slow high 20.0 film false false 720x428 102.0 1241.99
"Thor_The_Dark_World" x264 3.1 "" slow high 20.0 film false false 720x428 113.6 890.70
"Thor_The_Dark_World" x264 3.1 "" slow high 20.0 film false false 720x428 113.8 890.70
"Thor_The_Dark_World" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 19.0 "" false false 720x428 42.6 684.11
"Thor_The_Dark_World" x265 auto strong-intra-smoothing=0:rect=0:aq-mode=1 medium main 20.0 "" false false 720x428 44.4 592.94
"Thor_The_Dark_World" x265 "" "" medium auto 20.0 "" false false 720x428 37.0 615.62
"Vicky_Cristina_Barcelona" x265 "" "" medium auto 20.0 "" false false 720x552 36.1 852.49
"Volt" x265 "" "" medium auto 20.0 "" false false 720x572 37.1 678.71
"Warm_Bodies" x265 "" "" medium auto 20.0 "" false false 720x428 38.9 608.24
</pre>


== Handbrake log summary ==
== Handbrake log summary ==

Latest revision as of 10:39, 3 September 2024

HandBrake is a powerful, yet easy to use video encoder for Linux.

Links

On this wiki
  • Dv — capture and transcode of DV tapes.

General

Configuration

  • Config files are stored in ~/.config/ghb
  • Other possible locations are ~/.var/app/fr.handbrake.ghb.

Tips

Encode a DVD title

  • Click Source.
  • Select DVD to encode, and select folder VIDEO_TS (don't open it), and click OK.

Benchmarks

  • Movie: Bad Teacher
  • All Audio.
  • All Subtitles.
Version PC CPU Freq S/C/T Encoder Preset Level Quality Encoding speed Video bitrate track0 (video) size Comment
Xenial zacxl0005 i5-4300U 1.90GHz 1/2/4 H.264 veryfast 4.0 20 (RF) 135.4 fps 983.24 kb/s 658 MB No decomb
Zesty zacxl0005 i5-4300U 1.90GHz 1/2/4 H.264 fast 3.1 20 (RF) 50.4 fps 1174.29 kb/s 786 MB Fast
Zesty kraken X5650 2.67GHz 2/6/6 H.264 fast 3.1 20 (RF) 163.9 fps 1151.50 kb/s 771 MB Fast
Zesty kraken X5650 2.67GHz 2/6/12 H.264 fast 3.1 20 (RF) 177.9 fps 1151.50 kb/s 771 MB Fast
Zesty kraken X5650 2.67GHz 2/6/12 H.264 veryfast 4.0 22 (RF) 332.8 fps 654.67 kb/s 438 MB Very fast, No decomb
Zesty kraken X5650 2.67GHz 2/6/12 H.264 veryfast 4.0 22 (RF) 351.0 fps 660.70 kb/s 442 MB Very fast
Zesty kraken X5650 2.67GHz 2/6/12 H.264 veryfast 4.0 20 (RF) 332.9 fps 952.46 kb/s 637 MB Legacy normal (No decomb default)
Zesty kraken X5650 2.67GHz 2/6/12 H.265 fast auto 20 (RF) 41.8 fps 706.52 kb/s 473 MB Legacy normal (No decomb default)
  • S/C/T: Socket(s), Core per Socket, Thred per Socket.

Best settings for DVD

Some interesting links:

  • Doesn't use CQ but VFR bitrate, which is not recommended by handbrake. I'll use CQ and check the resulting bitrate, and reencode if too high / low. Recommended bitrate here is 1800-2200.

Notes

Notes:

  • Asking google (handbrake best settings for dvd, etc).
  • H265 doesn't seem to bring lot of advantage over H264, because H265 is mainly for highres video, which DVD isn't. H265 is much much slower however.

Handbrake presets:

  • HQ 576p25 Surround: H.264, RF:18, Peak Framerate, Constant Quality, Preset slow, Tune none, Profile high, Level 3.1.
  • SuperHQ 576p25 Surround: H.264, RF:16, Peak Framerate, Constant Quality, Preset veryslow, Tune none, Profile high, Level 3.1, more settings ref=5:bframes=5.

Using:

  • Starting from HQ 576p25.
  • Set Tune to film.
  • Set Filters, Deblock, to Light (and tune medium); denoise filter to HQDN3D, preset medium. Interlace detection to Default, Deinterlace to Decomb.
  • Audio, select all language, in auto passthrough.
  • Subtitles, all subtitles, no burn in.
  • Bench: Bad Teacher, x264, denoise, deblock, decomb: 96.99 / 95.70 fps, 2357MB, 1672kbps. But strange artefacts in generic (around statue, also around the text in generic).
  • Bench: Bad Teacher, x264, decomb, RF 18, slow: 81.93 fps, 2511 MB, 1881 kbps. Better output, but bigger and slower.
  • Bench: Bad Teacher, x264, decomb, denoise medium, RF 18, slow: 97.36 fps, 2206MB, 1445kbps, pretty much same quality as "decomb", but smaller and faster...
  • Bench: Bad Teacher, x264, decomb, denoise light , RF 18, slow: 93.07 fps, 2266MB, 1536kbps.
  • Bench: Bad Teacher, x264, decomb, denoise light , lapsharplightfilm, RF 18, slow: 83.07 fps, 2394MB, 1726kbps.
  • Bench: Bad Teacher, x264, decomb, denoise light , RF 20, slow: 108.46 fps, 1954MB, 1070kbps.
  • Bench: Bad Teacher, x264, decomb, denoise medium, RF 16, slow: 86.15 fps, 2629MB, 2077kbps.
  • Bench: Bad Teacher, x264, decomb, denoise medium, RF 18, slower: 64.24 fps, 2213MB, 1456kbps,
  • Bench: Bad Teacher, x264, decomb, denoise medium, 2-pass CBR 1800: 90.83+95.99 fps, 2443MB, 1800kbps,
  • Bench: Bad Teacher, x264, decomb, denoise medium, 2-pass CBR 1800 turbo 1st pass: 252.61+97.87 fps, 2442MB, 1800kbps,
  • Bench: Bad Teacher, x265, decomb, denoise light , RF 20, slow: 23.62 fps, 1743MB, 754kbps.
  • Bench: Bad Teacher, x265, decomb, denoise light , RF 20, medium: 42.97 fps, 1688MB, 672kbps.
  • Bench Final Cut, decomb, denois light, RF 18, slow, audio AAC 192: 73.59fps, 2238MB, 3103kbps. Audio very soft.
  • Bench Final Cut, decomb, denois medium, RF 18, slow, audio AC3 passthrough 192: 78.35fps, 2001MB, 2734kbps.
  • Bench Final Cut, decomb, denois medium, RF 20, slow, audio AC3 passthrough 192, dimension 720x576, ratio 1.66:1: 89.06fps, 1418MB, 1821kbps.

Template to try:

  • DVD x264
  • DVD x264, RF 19.
  • DVD x264, RF 18.
  • DVD x264 + AAC conversion (BUG ? When selecting AAC, it seems the gain is set to -20DB in Track List although it shows 0 in the Track selection, make sure to correct it)
  • DVD x265
  • DVD x265, RF 19.

Issues:

  • DVD 'Thor the Dark World' - HB picked the wrong main title. Must check that the picked title is correct.
  • When selected AAC conversion, there is gain -20db although it show 0db. Make sure it is set to 0db.

Things to try:

Subtitles

  • Which subtitle choose?
  • All of them, but assuming they can be displayed correctly.
  • Subtitle seems to be "VOBSUB".
  • Make a test on Plex on Shield.
  • Make a test on Plex on Chrome.
  • Make a test with VLC.
  • Make a test with mplayer.

Audio

  • Which audio track to choose?
  • VO + French
  • Should we take Dutch if available?
  • Which codec to use?
  • Ideally passthrough is best, but if AC3, it cannot directplay on Shield TV, which is a bit annoying.
  • If transcoding to AAC, audio is very soft. Should we use dynamic range? Should we normalize loudness?
  • AAC is greatly superior to AC3. AAC is transparent for 5.1ch at 320kb, for 2.0ch at 128kb.
  • If transcoding,
  • make sure there is no negative audio gain (note there is a bug in HB that by default set the gain to -20db). Better leave the gain at 0db.
  • select same mixdown as source.

Video

x265
  • From tests, medium preset Q 20.00 encodes as fast as medium preset Q 19.00, but the latter produces bigger (better quality) video.

To try:

  • x265 Q20.00 medium
  • x265 Q19.00 medium
  • x265 Q18.00 medium
  • x265 Q18.00 slow

Video - aspect ratio

Note:

  • 16:9 = 1.77:1 = 1024 x 576 = 1920 x 1080 (assuming square pixels).
  • 16.7:9 = 1.85:1 = 1024 x 552.
  • 4:3 = 12:9 = 1.33:1 = 1024 x 768 = 1920 x 1440 (assuming square pixels).
  • Pixel Aspect Ratio (PAR)
  • This is the pixel ratio to use when displaying an image.
  • 1:1 means the stored image assume square pixels.
  • 64:45 is the pixel ratio to use to change a 720x576 image into a 16:9 image 1024x576 (we have 720 / 45 * 64 = 1024)
  • 720x576 is an image with ratio 5:4 assuming square pixel, but it becomes 16:9 assuming pixel ratio 64:45.
  • To be displayed on a monitor with square pixels, then the 720x576 image must be stretched to 1024x576 image to preserved the final image ratio 16:9.
  • With 720x576 image,
  • a 16:15 PAR gives an image aspect ratio of 4:3.
  • a 64:45 PAR gives an image aspect ratio of 16:9.
  • Which aspect ratio?
  • DVD PAL is always 720x576, but handbrake automatically crops to remove black edges.
  • So resulting image cannot simply be panned to fit say 1920x1080 (16:9) display. The best fit must respect the desired aspect ratio.
  • In addition, some DVD does not document the aspect ratio correctly.
  • Ask Google to get correct a/r (final cut dvd aspect ratio, bad teacher dvd aspect ratio).
  • For handbrake, we have to define:
  • Storage geometry, the size of the encoded image, which is the size of the source after cropping.
  • Display geometry, the size of the image to be displayed on screen, which is the size of the source after cropping.
  • Examples
  • DVD Final Cut, 1998
  • Internet lookup: release ratio is 1.66:1.
  • This seems like a bad DVD rip. Viewing the DVD shows an image ratio of 4:3.
  • HB detects an issue with PAR: Video PAR 16:15 (ie. 4:3 image) != conainer PAR 64:45 (ie. 16:9 image). It defaults back to 16:9
  • HB detects image as 720x576 with 12/14/14/10 autocrop, ie. 694x552, image 16:9, PAR 64:45.
  • To correct the image ratio, we remove all crop (to keep the bar / pillar, which seem to be intended), and set the display geometry to 956 x 576.
  • DVD Bad Teacher, 2011
  • Internet look-up: movie aspect ration is 1.85:1.
  • HB detects image as 720x576 with 12/12/0/0 autocrop, ie. 720x552, image 16:9 PAR 64:45.
  • HB sets encode size at 720x552, and display size at 1024x552, with standard PAR 64:45, which gives the correct ratio 16.7:1, aka 1.85:1.

Plex Tests

Media:

  • x264 with AC3
  • x264 with AC3 with VOBSUB subtitles
  • x264 with AAC
  • x264 with AAC with VOBSUB subtitles
  • x265
  • x265 with VOBSUB subtitles

Plex Server:

  • Only trying ShieldTV

Plex Player:

  • Plex in Chrome.
  • Plex Add On in Kodi on ShieldTV.
  • Plex APp on ShieldTV.

Things to check:

  • Quality
  • Direct Play, Direct Stream or transcoding?
  • If transcoding, video or audio, or both?
  • Delay to start playing.

Things to try:

  • Plex Web -> Quality -> Uncheck 'Use Recommended settings', and make sure 'Maximum' is selected.

General Issues on Plex App:

  • Bad video AR when disabling HDMI passthrough (likely due to bad transcoding.)
  • AAC audio seems softer than AC3, although it should be the same.

Results:

  • Bad Teacher - H264 / AC3 5.1 (plex version: 480p, 2Mbps)
  • Plex on Chrome (Debian Buster): transcode AV (quality loss), showing 1Mbps on server.
  • ... but we can set the quality in the player: settings -> quality -> original! When doing so: Direct V (pixel same), transcode A, with 2Mbps showing on server.
  • Changing subtitles when playing: no delay.
  • Plex App on ShieldTV: Direct AV, 32s delay to start playing / resuming.
But with HDMI audio passthrough disabled: Direct V / Transcode A. Transcode reason: AC-3 audio is not supported by the device. Also video AR changed to 4:3 although Display Mode is still Letterbox. But only 8s to start playing!!! Audio also softer because AAC likely.
  • Plex Kodi on ShieldTV: '.
  • same + VOBSUB
  • Plex on Chrome (Debian Buster): transcode AV (quality loss).
  • Plex App on ShieldTV: Direct AV, 32s delay to start playing / resuming.
But with HDMI audio passthrough disabled: Transcode V / Transcode A. Transcode reason: AC-3 audio is not supported by the device. Video AR is normal. But only 8s to start playing!!! Audio also softer because AAC likely.
... tried a second time with HDMI audio disabled: Direct V / Transcode A. 8s to start playing. Video AR is again 4:3. So it seems Direct V loses the video AR, while Transcode V keeps AR.
  • Plex Kodi on ShieldTV: '.
  • Bad Teacher - H264 / AAC 5.1 (plex version: 480p, 1.8Mbps)
  • Plex on Chrome (Debian Buster): Direct AV (pixel same).
  • Plex App on ShieldTV: Direct AV, 32s delay to start playing / resuming. Audio is softer than AC3
same with HDMI audio passthrough disabled.
  • Plex Kodi on ShieldTV: '.
  • same + VOBSUB
  • Plex on Chrome (Debian Buster): Direct Audio, Transcode Video (slight quality loss), showing 2Mbps on server, client says 'Convert (Maximum), 1.8Mbps'.
  • Plex App on ShieldTV: Direct AV, 32s delay to play from start.
same with HDMI audio passthrough disabled.
  • Plex Kodi on ShieldTV: '.
  • Bad Teacher - HEVC / AC3 5.1 (plex version: 480p, 1.6Mbps)
  • Plex on Chrome (Debian Buster): Transcode AV (slight quality loss), showing 3 Mbps on server.
  • Plex App on ShieldTV: Direct AV. Video AR ok. Startup 32s.
But with HDMI audio passthrough disabled: Direct V / Transcode A. Bad video AR 4:3. Startup only 8s.
  • Plex Kodi on ShieldTV: '.
  • same + VOBSUB
  • Plex on Chrome (Debian Buster): Transcode AV (slight quality loss), showing 3 Mbps on server, client says 'Convert (Maximum), 1.6Mbps'.
  • Plex App on ShieldTV: Direct AV. Video AR ok. Startup 32s.
But with HDMI audio passthrough disabled: Direct V / Transcode A. Bad video AR 4:3. Startup only 8s.
  • Plex Kodi on ShieldTV: '.
  • Brave H264 / AC3 5.1 (SD, 2.6Mbps )
  • Plex App on ShieldTV: DirectAV. Same with VOBSUB.
  • Brave H264 / AAC 5.1 (SD, 1.9Mbps )
  • Plex App on ShieldTV: DirectAV. Same with VOBSUB.
  • Brave HEVC / AAC 5.1 (SD, 1.6Mbps )
  • Plex App on ShieldTV: DirectAV. Same with VOBSUB.

Plex Tests - other videos

THese are test results with videos not produced by HandBrake:

  • Interstellar - .MP4 - H264 / AAC stereo
  • Plex App on Shield: Direct AV, 8s delay only. Also with External SRT.
  • Plex Kodi on Shield: Direct *Play* AV. 3s max delay.

Test summary

Using the script below.

  • Filters are not shown (decomb or denoise may significantly change the FPS / BITRATE).
PATH                                   ENCODER  LEVEL  OPTIONS                                    PRESET    PROFILE  QUALITY  TUNE  TURBO  TWOPASS  SIZE     FPS    BITRATE  FPS   BITRATE
"21_Grams"                             x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x552  109.9  2195.60
"Abduction"                            x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  36.3   755.53
"Arthur_et_les_minimoys_2"             x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x436  30.1   1228.08
"Arthur_et_les_minimoys_3"             x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x438  29.2   1430.21
"Arthur_et_les_Minimoys"               x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x432  36.4   1019.37
"Babel"                                x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x556  31.0   894.37
"Bad_Teacher"                          x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x552  163.2  1151.62
"Bad_Teacher"                          x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x552  163.8  1151.62
"Bad_Teacher"                          x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x552  177.9  1151.63
"Bad_Teacher"                          x264     3.1    ""                                         slower    high     18.0     film  true   true     720x552  64.2   1456.83
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     16.0     film  true   true     720x552  86.1   2077.35
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  81.9   1901.26
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  83.0   1726.80
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  88.7   1702.91
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  93.0   1536.69
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  93.2   1536.69
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  95.7   1672.58
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  96.9   1672.58
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     18.0     film  false  false    720x552  97.3   1445.91
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     19.0     film  false  false    720x552  99.5   1276.99
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     20.0     film  false  false    720x552  106.6  1070.31
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     20.0     film  false  false    720x552  107.6  1070.31
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     20.0     film  false  false    720x552  108.4  1070.31
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     ""       film  false  true     720x552  90.8   1780.17  95.9  1799.93
"Bad_Teacher"                          x264     3.1    ""                                         slow      high     ""       film  true   true     720x552  252.6  1781.79  97.8  1799.60
"Bad_Teacher"                          x264     4.0    ""                                         veryfast  main     20.0     ""    false  false    720x552  332.8  952.46
"Bad_Teacher"                          x264     4.0    ""                                         veryfast  main     22.0     ""    false  false    720x552  332.7  654.67
"Bad_Teacher"                          x264     4.0    ""                                         veryfast  main     22.0     ""    false  false    720x552  350.9  660.70
"Bad_Teacher"                          x265     auto   ""                                         medium    auto     20.0     ""    false  false    720x552  39.9   778.46
"Bad_Teacher"                          x265     auto   ""                                         medium    auto     20.0     ""    false  false    720x552  41.7   706.52
"Bad_Teacher"                          x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     19.0     ""    false  false    720x552  41.1   789.73
"Bad_Teacher"                          x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     20.0     ""    false  false    720x552  42.9   672.42
"Bad_Teacher"                          x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     20.0     ""    false  false    720x552  43.2   672.42
"Bad_Teacher"                          x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  slow      main     20.0     ""    false  false    720x552  23.6   754.62
"Bad_Teacher"                          x265     auto   threads=2                                  medium    auto     20.0     ""    false  false    720x552  38.7   910.50
"Bad_Teacher"                          x265     auto   :threads=2                                 medium    auto     20.0     ""    false  false    720x552  46.8   627.42
"Beignets_de_Tomates_Vertes"           x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x550  33.8   879.23
"Bienvenue_à_bord"                     x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  34.6   872.17
"Black_Swan"                           x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  37.6   829.10
"Brave"                                x264     3.1    ""                                         slow      high     18.0     film  false  false    720x428  92.3   1572.53
"Brave"                                x264     3.1    ""                                         slow      high     19.0     film  false  false    720x428  98.4   1342.36
"Brave"                                x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  102.6  1148.41
"Brave"                                x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  104.3  1148.41
"Brave"                                x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     19.0     ""    false  false    720x428  38.8   873.15
"Brave"                                x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     20.0     ""    false  false    720x428  40.5   754.75
"Brave"                                x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  34.6   779.28
"Brooklyn"                             x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  39.5   587.93
"Cars"                                 x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x426  37.4   1258.09
"Cloverfield"                          x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x570  30.3   1039.41
"Crash"                                x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x572  34.2   683.68
"Crazy_Stupid_Love"                    x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x426  39.4   593.34
"Fanny"                                x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  36.3   857.03
"FINAL_CUT_1998_PAL_DVD5-mOe.iso"      x264     3.1    ""                                         slow      high     18.0     film  false  false    720x576  73.5   3103.34
"FINAL_CUT_1998_PAL_DVD5-mOe.iso"      x264     3.1    ""                                         slow      high     18.0     film  false  false    720x576  78.3   2734.55
"FINAL_CUT_1998_PAL_DVD5-mOe.iso"      x264     3.1    ""                                         slow      high     20.0     film  false  false    720x576  89.0   1821.75
"FitnessExpander"                      x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x432  30.8   2089.19
"Ghost_in_a_Shell"                     x265     ""     ""                                         medium    auto     20.0     ""    false  false    708x544  45.3   662.16
"Hanna"                                x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x428  128.9  855.14
"Hanna"                                x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  41.4   536.65
"Hansel_and_Gretel_Witch_Hunters"      x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  34.9   766.68
"Harold_and_Maude"                     x265     ""     ""                                         medium    auto     20.0     ""    false  false    704x576  33.0   955.33
"Harry_Potter_5_Order_of_the_Phoenix"  x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x424  189.9  1067.77
"Harry_Potter_5_Order_of_the_Phoenix"  x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x424  190.6  1067.78
"Hotel_Transylvania"                   x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  34.1   828.61
"Howls_Moving_Castle"                  x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  41.9   1245.70
"Inspecteur_la_Bavure"                 x265     ""     ""                                         medium    auto     20.0     ""    false  false    660x576  30.2   1169.45
"Interstellar"                         x264     3.1    ""                                         slow      high     18.0     film  false  false    720x428  99.2   1217.00
"Interstellar"                         x264     3.1    ""                                         slow      high     19.0     film  false  false    720x428  106.7  1031.81
"Interstellar"                         x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  112.7  880.15
"Interstellar"                         x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  114.3  880.15
"Interstellar"                         x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     19.0     ""    false  false    720x428  41.9   680.24
"Interstellar"                         x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     20.0     ""    false  false    720x428  43.9   586.21
"Interstellar"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  37.6   605.70
"Joan_of_Arc_-_FR"                     x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x432  36.7   838.71
"Joan_of_Arc"                          x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x432  36.4   838.71
"La_Fée"                               x264     3.1    ""                                         fast      main     20.0     ""    false  false    718x576  138.9  985.62
"La_Fée"                               x264     3.1    ""                                         fast      main     20.0     ""    false  false    718x576  176.5  985.62
"La_Fille_du_Puisatier"                x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  29.2   1499.65
"La_Moustache"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  35.1   898.51
"La_Soupe_aux_Choux"                   x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x436  139.6  1060.86
"La_Soupe_aux_Choux"                   x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x436  185.8  1060.86
"Le_Baron_de_Munchausen"               x264     3.1    ""                                         fast      main     20.0     ""    false  false    702x552  128.6  2006.41
"Le_Baron_de_Munchausen"               x264     3.1    ""                                         fast      main     20.0     ""    false  false    702x552  144.3  2006.41
"L_ecume_des_Jours"                    x264     3.1    ""                                         fast      main     20.0     ""    false  false    720x554  184.0  1268.97
"Le_Gendarme_et_les_Extra-Terrestres"  x264     3.1    ""                                         fast      main     20.0     ""    false  false    660x576  173.7  1862.95
"Le_Grand_Blond"                       x264     3.1    ""                                         fast      main     20.0     ""    false  false    678x576  197.4  1568.68
"Le_Retour_du_Grand_Blond"             x264     3.1    ""                                         fast      main     20.0     ""    false  false    700x576  185.9  1592.53
"Les_Aventures_De_Rabbi_Jacob"         x264     3.1    ""                                         fast      main     20.0     ""    false  false    678x576  149.1  2842.31
"Les_Aventures_du_Baron_Munchausen"    x264     3.1    ""                                         fast      main     20.0     ""    false  false    702x552  151.3  2006.41
"Les_Comperes"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    658x576  27.0   1647.45
"Les_Enfants_de_Timpelbach"            x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x436  35.5   1102.33
"Les_Femmes_ou_les_Enfants_d_abord"    x264     3.1    ""                                         fast      main     20.0     ""    false  false    702x432  111.3  1369.30
"Les_Femmes_ou_les_Enfants_d_abord"    x264     3.1    ""                                         fast      main     20.0     ""    false  false    718x432  139.5  1256.70
"Les_Fugitifs"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    656x576  30.3   1250.70
"Let_Me_In"                            x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x428  54.7   327.30
"Let_the_Right_One_In"                 x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x436  53.3   359.90
"Lucas_Fourmi_Malgre_Lui"              x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x428  37.6   694.53
"Marius"                               x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  33.9   906.23
"Mission_Cleopatre"                    x265     ""     ""                                         medium    auto     20.0     ""    false  false    716x432  33.7   905.42
"Populaire"                            x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x556  40.2   540.47
"Pretty_Woman"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    706x542  40.2   748.25
"prometheus"                           x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x424  45.6   497.97
"Pulp_Fiction"                         x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x436  47.9   538.03
"Qu_est-ce_qu_on_a_fait_au_bon_dieu"   x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  36.3   930.70
"Rio"                                  x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x428  36.6   752.25
"RTT"                                  x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x432  31.2   1144.21
"Serenity"                             x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x436  41.4   664.90
"Stand_by_Me"                          x265     ""     ""                                         medium    auto     20.0     ""    false  false    702x550  35.5   1025.44
"The_Sister_Act_2"                     x265     ""     ""                                         medium    auto     20.0     ""    false  false    718x576  36.4   835.03
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     18.0     film  false  false    720x428  101.1  1211.24
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     18.0     film  false  false    720x428  92.4   1666.77
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     19.0     film  false  false    720x428  107.6  1036.66
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     19.0     film  false  false    720x428  95.2   1437.17
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  100.8  1241.99
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  102.0  1241.99
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  113.6  890.70
"Thor_The_Dark_World"                  x264     3.1    ""                                         slow      high     20.0     film  false  false    720x428  113.8  890.70
"Thor_The_Dark_World"                  x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     19.0     ""    false  false    720x428  42.6   684.11
"Thor_The_Dark_World"                  x265     auto   strong-intra-smoothing=0:rect=0:aq-mode=1  medium    main     20.0     ""    false  false    720x428  44.4   592.94
"Thor_The_Dark_World"                  x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  37.0   615.62
"Vicky_Cristina_Barcelona"             x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x552  36.1   852.49
"Volt"                                 x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x572  37.1   678.71
"Warm_Bodies"                          x265     ""     ""                                         medium    auto     20.0     ""    false  false    720x428  38.9   608.24

Handbrake log summary

Here a script to summarize handbrake logs:

#! /bin/bash
# 
#  Usage:
#    cd <handbrake_log_folder>
#    ./summary.sh
#
#    # This also produces a file (+copy with timestamp) summary-last.txt
#
#    # x265 only | sort by Fps
#    ./summary.sh | grep x265 | sort -nk 12
#    # x265 only | sort by Bitrate
#    ./summary.sh | grep x265 | sort -nk 13

summary() 
{
  # echo "----- [$F] --------------------------------"
  F="$1"
cat "$F" |
  sed -rn '/"(width|height|Path|Video|ColorMatrixCode|Encoder|Level|OpenCL|Options|Preset|Profile|QSV|AsyncDepth|Decode|Quality|Tune|Turbo|TwoPass)"|work: average encoding speed for job is|encoded [0-9]+ frames in [0-9.]+s \([0-9.]+ fps\), [0-9.]+ kb\/s, Avg QP:[0-9.]+|x264 \[info\]: kb\/s:[0-9.]+/p;' |
  sed -r '/^ +("Encoder": "(copy:ac3|av_aac)"|"Quality": -3.0,|"ColorMatrixCode": 0|"OpenCL": false|"(QSV|Video)": \{|"AsyncDepth": 4|"Decode": false),?$/d' |
  sed -r 's/\/VIDEO_TS//' | 
  sed -r '/"Path"/b a; s/: "([^"]+)"/: \1/; :a s/"([^"]+)":/\1:/' | 
  sed -r '/Path:/s/"[^"]+\/([^"/]+)"/"\1"/' | 
  sed -r 's/^.* work: average encoding speed for job is ([0-9.]+) fps/        Fps: \1,/' |
  sed -r 's/^x264 \[info\]: kb\/s:([0-9.]+)/        Bitrate: \1,/' | 
  sed -r 's/^encoded [0-9]+ frames in [0-9.]+s \([0-9.]+ fps\), ([0-9.]+) kb\/s, Avg QP:[0-9.]+/        Bitrate: \1,/' |
  sed -r '/Fps: 0.000000/d; /Fps/s/(\.[0-9])[0-9]+/\1/'

#    "Video": {
#        "ColorMatrixCode": 0,
#        "Encoder": "x265",
#        "Level": "",
#        "OpenCL": false,
#        "Options": "",
#        "Preset": "medium",
#        "Profile": "auto",
#        "QSV": {
#            "AsyncDepth": 4,
#            "Decode": false
#        },
#        "Quality": 20.0,
#        "Tune": "",
#        "Turbo": false,
#        "TwoPass": false
# work: average encoding speed for job is 38.982147 fps
# encoded 140689 frames in 3609.03s (38.98 fps), 608.24 kb/s, Avg QP:24.41
}

# Remove all known fields
#     Path:"[-/a-zA-Z0-9_.()+ ]+"|
#     Encoder:(x264|x265)|
#     Level:(""|3.1|4|4.0|auto)|
#     Options:(""|:threads=2|threads=2|strong-intra-smoothing=0:rect=0:aq-mode=1)|
#     Preset:(veryfast|fast|medium|slow|slower)|
#     Profile:(auto|main|high)|
#     Quality:(16.0|18.0|19.0|20.0|22.0)|
#     Tune:(""|film)|
#     Turbo:(false|true)|
#     TwoPass:(false|true)|
#     Fps:[0-9.]+|
#     Bitrate:[0-9.]+
filter_known_fields()
{
  sed -r '/^-+ \[[-/a-zA-Z0-9_.()+ ]+\] -+$/d' |
    sed -r '/^ *(height: (424|426|428|432|436|438|542|544|550|552|554|556|570|572|576|[0-9]+)|width: (656|658|660|678|700|702|704|706|708|716|718|720|[0-9]+)|Path: "[^"/]+"|Encoder: (x264|x265)|Level: (""|3.1|4|4.0|auto)|Options: (""|:threads=2|threads=2|strong-intra-smoothing=0:rect=0:aq-mode=1)|Preset: (veryfast|fast|medium|slow|slower)|Profile: (auto|main|high)|Quality: (16.0|18.0|19.0|20.0|22.0)|Tune: (""|film)|Turbo: (false|true)|TwoPass: (false|true)|Fps: [0-9.]+|Bitrate: [0-9.]+),?$/d'
    # sed -r '/^ +(Path: "(\/home\/baddreams\/handbrake-tests|\/smb\/(lacie-cloudbox|wolverine)\/family\/(movie|Movies)|\/smb\/mnemosyne\/movies?\/(new|parents|parents_new|children|comedy-action)(_new|_convert|_converted)?)\/[-/a-zA-Z0-9_.()+ ]+"),?$/d' |
# Typical summary:
#
# ----- [21 Grams 2017-07-24 01-12-43.log] --------------------------------
#         height: 552,
#         width: 720
#         Path: "21 Grams",
#         Encoder: x264,
#         Level: 3.1,
#         Options: "",
#         Preset: fast,
#         Profile: main,
#         Quality: 20.0,
#         Tune: "",
#         Turbo: false,
#         TwoPass: false
#         Fps: 109.9,
#         Bitrate: 2195.60,
}

one_liner()
{
  sed -r ' s/: /:/; s/^ +//; s/ /_/g; s/,$//' | sed -r ':a N; s/\n/ /g; b a' | sed -r '/Fps:/!d; s/^height:([0-9]+) width:([0-9]+) (.* TwoPass:(true|false)) (.*)/\3 \2x\1 \5/; s/(Profile:[^ ]+) Tune:/\1 Quality:"" Tune:/; s/(Path|Encoder|Level|Options|Preset|Profile|Quality|Tune|Turbo|TwoPass|Fps|Bitrate)://g'
}

summarize()
{
  echo "PATH ENCODER LEVEL OPTIONS PRESET PROFILE QUALITY TUNE TURBO TWOPASS SIZE FPS BITRATE FPS BITRATE"
  for F in *.log; do
    summary "$F" | one_liner
  done | sort -n
}

UNKNOWN=0
for F in *.log; do
  summary "$F" | filter_known_fields
  UNKNOWN=$(( UNKNOWN + $(summary "$F" | filter_known_fields | wc -l) ))
done

[ $UNKNOWN -eq 0 ] || echo "### UNKNOWN FIELDS IN SUMMARY ##############"
summarize | column -t | tee summary-last.txt
cp summary-last.txt summary-$(date +"%Y%m%d-%H%M%S").txt