HandBrake: Difference between revisions

From miki
Jump to navigation Jump to search
Line 237: Line 237:
:* 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.

== Handbrake log summary ==
Here a script to summarize handbrake logs:
<source lang="bash">
#! /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
</source>

Revision as of 23:41, 2 January 2021

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

Links

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 - 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.

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