2024-12-03, 02:18 AM
(This post was last modified: 2024-12-03, 04:10 AM by bitmap. Edited 1 time in total.)
Back to an old discussion @TheDreadPirate and I had regarding auto-cropping (if you trust cropdetect at all). I snagged some awk from somewhere and another person offered an expansion that sorts all results from a sample size of your choice and selects the one which occurs most often in cropdetect output. Pretty cool, actually!
In my experience, past black screens and REALLY dark scenes, this is a thoroughly accurate way to crop out black bars. Then you would use this variable in your filter:
Make sure to crop prior to other hardware-based filters (e.g., vpp_qsv) or you'll need to use hwdownload and figure out formats. Easier just to crop from the start.
Okay, so using the crop filter with ANY hw-based filters doesn't seem to work at all. However, you can utilize vpp_qsv to the same effect with a tiny bit of extra work (which I've already done):
And then your vpp_qsv filter would look like this:
Of course with hwupload and denoise optional, just copy/pasted from my script. If scaling, you have to use a separate filter (e.g., scale_qsv) as it doesn't seem to respect scale_mode, w, and h parameters when using crop functions.
Code:
REMOVED
In my experience, past black screens and REALLY dark scenes, this is a thoroughly accurate way to crop out black bars. Then you would use this variable in your filter:
Code:
REMOVED
Make sure to crop prior to other hardware-based filters (e.g., vpp_qsv) or you'll need to use hwdownload and figure out formats. Easier just to crop from the start.
Okay, so using the crop filter with ANY hw-based filters doesn't seem to work at all. However, you can utilize vpp_qsv to the same effect with a tiny bit of extra work (which I've already done):
Code:
cropval=$(jffmpeg -ss 120 -i "${i}" -t 5:00 -filter:v fps=1/2,cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tr ' ' '\n' | sort | uniq -c | sort -n | tail -1 | awk '{ print $NF }') && \
cw=$(echo "${cropval#*crop=}" | cut -d : -f 1) && ch=$(echo "${cropval#*crop=}" | cut -d : -f 2) && \
cx=$(echo "${cropval#*crop=}" | cut -d : -f 3) && cy=$(echo "${cropval#*crop=}" | cut -d : -f 4) && \
And then your vpp_qsv filter would look like this:
Code:
-filter:v "hwupload=extra_hw_frames=64,vpp_qsv=cw=$cw:ch=$ch:cx=$cx:cy=$cy:denoise=6"
Of course with hwupload and denoise optional, just copy/pasted from my script. If scaling, you have to use a separate filter (e.g., scale_qsv) as it doesn't seem to respect scale_mode, w, and h parameters when using crop functions.
Jellyfin 10.10.0 LSIO Docker | Ubuntu 24.04 LTS | i7-13700K | Arc A380 6 GB | 64 GB RAM | 79 TB Storage