我试着用不同的尺度或大小或(高度*宽度)使用Mobile-FFmpeg #创建一个视频。
我使用这个代码脚本来获得所需的结果:
val filterStringBuilder1 = StringBuilder()<br />
filterStringBuilder1.append(listOfImages)<br />
filterStringBuilder1.append("-filter_complex ")<br />
filterStringBuilder1.append(<br />
"[0:v]scale=100:140:force_original_aspect_ratio=decrease,pad=100:140:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=4:d=1[v0];" +<br />
"[1:v]scale=180:120:force_original_aspect_ratio=decrease,pad=180:120:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1];" +<br />
"[2:v]scale=120:180:force_original_aspect_ratio=decrease,pad=120:180:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2];" +<br />
"[v0][v1][v2]concat=n=3:v=1:a=0,format=yuv420p[v]")<br />
filterStringBuilder1.append(" -map")<br />
filterStringBuilder1.append(" [v] ")<br />
filterStringBuilder1.append("-aspect 16:9 ")<br />
filterStringBuilder1.append(finalVideo.absolutePath)<br />
FFmpeg.execute(filterStringBuilder1.toString())<br />
但是,查找以下logcat错误:
E/mobile-ffmpeg: [Parsed_concat_14 @ 0x748fc98bc0] <br />
E/mobile-ffmpeg: Input link in1:v0 parameters (size 180x120, SAR 1:1) do not match the corresponding <br />output link in0:v0 parameters (100x140, SAR 1:1)<br />
E/mobile-ffmpeg: [Parsed_concat_14 @ 0x748fc98bc0] <br />
E/mobile-ffmpeg: Failed to configure output pad on Parsed_concat_14<br />
E/mobile-ffmpeg: Error reinitializing filters!<br />
E/mobile-ffmpeg: Failed to inject frame into filter network: Invalid argument<br />
E/mobile-ffmpeg: Error while processing the decoded data for stream #2:0<br />发布于 2021-01-21 17:59:04
连接滤波器的所有输入必须具有相同的大小(宽度x高度)和高宽比。你不需要连接。你得加起来。将动画规模与覆盖一起使用。简化的ffmpeg命令行示例,3幅图像从0到100%覆盖在背景图像上.
ffmpeg -loop 1 -t 10 -i background.jpg -loop 1 -i img1.png -loop 1 -i img2.jpg -loop 1 -i img3.jpg -filter_complex "[1]scale=eval=frame:w='min(iw*t,iw)':h=-1[img1];[2]scale=eval=frame:w='min(iw*t,iw)':h=-1[img2];[3]scale=eval=frame:w='min(iw*t,iw)':h=-1[img3];[0][img1]overlay=(W-w)/2:(H-h)/2:shortest=1:format=auto[bg];[bg][img2]overlay=shortest=1:format=auto[bg2];[bg2][img3]overlay=W-w:H-h:shortest=1:format=auto,format=yuv420p" output.mp4https://stackoverflow.com/questions/65825692
复制相似问题