Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

FFmpeg - Turn a 1280x720 video into 720x1280 video and add blur

I've searched around and found multiple solutions. I've found one that works well, but the final video ends up being too big which makes the rendering slow.

I'm giving it a 1280x720 video and want it to turn out like shown here with 720x1280 as the resolution.

-lavfi "[0:v]scale=256/81*iw:256/81*ih,boxblur=luma_radius=min(h,w)/40:luma_power=3:chroma_radius=min(cw,ch)/40:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,setsar=1,crop=w=iw*81/256"

This video ends up being 1280x2274 instead of 720x1280, everything else is fine except the speed and resolution.

-lavfi [0:v]scale=16/9*iw:16/9*ih,boxblur=luma_radius=min(h,w)/40:luma_power=3:chroma_radius=min(cw,ch)/40:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,setsar=1,crop=w=720:h=1280

This cuts the original video, but ends up being 720x1280, faster than the first solution.

-lavfi "[0:v]scale=256/81*iw:256/81*ih,boxblur=luma_radius=min(h,w)/40:luma_power=3:chroma_radius=min(cw,ch)/40:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,setsar=1,crop=w=iw*81/256,scale=720:1280"

This is the same as the first one, but it gets scaled again. It has the correct resolution, but is way to slow for my liking (only about 3.6 it/s, when I've tried other solutions which fluctuates around 35 it/s).

I guess my scaling is wrong, but I don't understand what I should multiply and divide by, to get the result I'm looking for.

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A simple way to change the resolution of a video using ffmpeg is

ffmpeg -i input.mp4 -vf "scale=1280*720" output.mp4

for add blur effect refer https://superuser.com/questions/901099/ffmpeg-apply-blur-over-face


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...