使用 FFmpeg 通过一个命令在视频中添加音频和水印

使用 FFmpeg 通过一个命令在视频中添加音频和水印

我想仅使用一个命令为视频添加音频和水印。目前我首先使用以下命令添加水印:

String[] cmd={"-i",videoPath,"-ignore_loop","0","-i","/storage/emulated/0/Download/heart.gif","-filter_complex","{1:v]format=yuva444p,scale="+1280+":"+-1+",setsar=1,rotate="+angle+":c=black@0:ow=rotw("+angle+"):oh=roth("+angle+") [rotate];[0:v][rotate] overlay="+0+":0:shortest=1","-codec:a","copy","-y","/storage/emulated/0/Movies/watermarker_center14.mp4"};

然后使用以下命令将音频添加到视频中:

String[] cmd1={"-i",videopath,"-i",audiopath,"-c:v","copy","-c:a","aac","-map","0:v:0","-map","1:a:0","-shortest",output};

执行命令并生成最终的视频需要很长时间。

答案1

使用

String[] cmd={"-i",videoPath,"-ignore_loop","0","-i","/storage/emulated/0/Download/heart.gif","-i",audiopath,"-filter_complex","{1:v]format=yuva444p,scale="+1280+":"+-1+",setsar=1,rotate="+angle+":c=black@0:ow=rotw("+angle+"):oh=roth("+angle+") [rotate];[0:v][rotate] overlay="+0+":0:shortest=1[v]","-map","'[v]'","-map","2:a:0","-c:a","aac","-shortest","-y","/storage/emulated/0/Movies/watermarker_center14.mp4"};

相关内容