yuanqing/vdx

Center the crop automatically

mrzool opened this issue · 1 comments

vdx starts cropping from x=0 by default. I have a bunch of letterboxed videos that I need to get back to their original ratio by cropping away the two black bars at the sides. Is there a smart way for centering the crop automatically, without having to calculate the x/y coordinates manually? Kind of like the -gravity center flag in imagemagick.

I was able to get ffmpeg to detect the crop coordinates automatically through cropdetect:

ffmpeg -i input.mp4 -vframes 10 -vf cropdetect -f null -

Sample output:

[Parsed_cropdetect_0 @ 0x7fcce1c04940] x1:246 x2:1681 y1:0 y2:1079 w:1424 h:1072 x:252 y:4 pts:2000 t:0.083333 crop=1424:1072:252:4

I then used the detected coordinates with vdx --crop, in this case:

vdx input.mp4 --crop 252,4,1424,1072

Maybe an idea for a built-in feature? :)