我想在视频上添加文本,我正在使用ffmpeg android lib,但编辑成功,但输出的视频仅显示黑屏
字符串addtextcommand [] = {“-i”,inputpath,“ -strict”,“ -2”,“ -vf”,“ drawtext = text = \'onLine1 \':fontcolor = white”,“ -map ”,“ 0:a”,“-codec:v”,“ libx264”,“-codec:a”,“ copy”,输出};
答案 0 :(得分:1)
问题出在"-map", "0:a"
,您正在忽略来自inputpath
的视频。尝试没有该命令的命令。
答案 1 :(得分:0)
我不会给您和解决方案,我更喜欢找出您的命令并自行找到解决方案,我将在这里向您解释命令
-i inputpath --> for Input (Video/GIF/IMAGES/MUSIC)
-strict -2 --> strictly conform to all the things in the spec no matter what consequences -2 for experimental
-vf --> for videofilter alternativaly you can use -filter_complex
drawtext=text='onLine1': fontcolor=white --> for draw text over on any med file like image or video
-map 0:a --> to map out with 1'st input auido 0:a stands for 1'st input audio
-codec:v --> for video codec
libx264 ---> specify video codec
-codec:a copy --> for audio codec , here you get audio codec from input copy stand s fro get codc from input
output --> final Output
尝试以下代码:
-i video.mp4 -filter_complex "drawtext=text=Vinesh Chauhan:fontcolor=#000000:fontsize=14:x=43:y=103:fontfile=FACEBOLF.OTF" -y output.mp4
对于android,您的命令应为
String[] cmd = new String[]{"-i",""+inputpath, "-filter_complex", "drawtext=text=Vinesh Chauhan:fontcolor=#000000:fontsize=14:x=43:y=103:fontfile="+fontPATH, "-y" ,""+outputpath};
现在,我认为如果下面的任何查询注释一定会对您有所帮助,您可以自行找到解决方案