嗨,我想使用 ffmpeg 制作圆形波形视频,但想使用背景图像。我多次尝试这个命令,但没有成功,我一遍又一遍地尝试使用 ChatGPT 但根本不起作用,现在我怀疑是否有可能在单个命令中完成它。
ffmpeg -i input.mp3 -i background.png -filter_complex "[0:a]showwaves=size=100x100:colors=white:draw=full:mode=p2p[v];[v]format=rgba,geq='p(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))'[vout];[1:v][vout]overlay=(W-w)/2:(H-h)/2[outv]" -map "[outv]" -map 0:a -pix_fmt yuv420p output.mp4
我在没有 bg 的情况下使用了这个命令,它有效:
ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=size=100x100:colors=white:draw=full:mode=p2p[v]; \[v]format=rgba,geq='p(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))'[vout]" -map "[vout]" -map 0:a -pix_fmt yuv420p output.mp4
在这种情况下,geq 滤波器需要 alpha 参数和您编写的方程来计算像素的透明度。
[v]format=rgba,geq='p(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))':a='1*alpha(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))'[vout]; // here
完整命令:
ffmpeg -i input.mp3 -i background.png -filter_complex "[0:a]showwaves=size=100x100:colors=white:draw=full:mode=p2p[v];[v]format=rgba,
geq='p(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))':a='1*alpha(mod((2*W/(2*PI))*(PI+atan2(0.5*H-Y,X-W/2)),W), H-2*hypot(0.5*H-Y,X-W/2))'[vout];[1:v][vout]overlay=(W-w)/2:(H-h)/2[outv]" -map "[outv]" -map 0:a -pix_fmt yuv420p output.mp4