alexheretic / vimg

CLI for video images. Generates animated video contact sheets fast.
MIT License
19 stars 2 forks source link

Aspect Ratio-based Sizing #7

Open juan-riveros opened 8 months ago

juan-riveros commented 8 months ago

Context

I tend to create a lot of VCSs of videos with heterogeneous aspect ratios. This means that setting -H or -W alone tends to be pretty painful as I'll have to go through and either reprocess them, or as I've done recently, utilize ffprobe to get the aspect ratio and create more consistently sized VCSs.

Feature Request

Probably would be better if there was a new vimg vcs option for the "longest side length". Then using the aspect ratio, selected whether to utilize -H or -W.

OTOH, maybe just a flag which sets the VCS width or height and then computes the necessary value for -H or -W instead?

Alternate Solutions/Workarounds

This is a script which utilizes ffprobe, if it's taller than wider, it'll use -W else it'll use -H.

for f in ./*.mp4; do
    aspect_ratio=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "$f" | awk -F 'x' '{print ($1/$2 > 1) ? "wider" : "taller"}')

    if [ "$aspect_ratio" == "taller" ]; then
        vimg vcs --columns 3 -f30 -t1500ms --avif-crf 25 --avif-fps 20 -W 320 --number 9 "$f"
    else
        vimg vcs --columns 3 -f30 -t1500ms --avif-crf 25 --avif-fps 20 -H 320 --number 9 "$f"
    fi
done

Reproduction

Use any normal YouTube Video and then a YouTube Short with xargs or a for-loop without the ffprobe trick and see how one video will be much smaller than expected.


PS. I want to thank you for such a great tool. It's been super helpful for culling my video archives.