Overlay in ffmpeg with subtitle

青春壹個敷衍的年華 提交于 2020-12-15 06:38:07

问题


I am struck with overlaying image and subtitles in FFmpeg, above is the command

ffmpeg -i bg.png -vcodec libvpx-vp9 -i test.webm -i test.png -y -filter_complex "[1:v]scale=1210:682[scale1];[scale1]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[rotate0];[0:v][rotate0]overlay=x=291.12:y=206.9[overlay0];[overlay0]subtitles=test.ass,overlay=x=291.12:y=206.9[textoverlay10];[2:v]scale=630:354[scale2];[scale2]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[rotate2];[textoverlay10][rotate2]overlay=x=737.13:y=50.87[overlay2];[overlay2]subtitles=test.ass,overlay=x=291.12:y=206.9" -pix_fmt yuv420p -t 10 ver.mp4 

I am getting the following error "Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_subtitles_3".Is this the correct way of overlay images, and subtitles? please correct me where I am going wrong.

If I add an image on top of it, please find below image


回答1:


Simplified example from your command

ffmpeg -loop 1 -i background.png -i bird.webm -filter_complex "[0]subtitles=subs.ass[bg];[bg][1]overlay=shortest=1,format=yuv420p" output.mp4

Example you can copy and paste

ffmpeg -f lavfi -i color=c=red:s=320x240,format=yuv444p -f lavfi -i color=c=green:s=280x200,format=yuv444p -f lavfi -i color=c=blue@0.5:s=80x80,format=yuva444p -filter_complex "[0][1]overlay=(W-w)/2:(H-h)/2,subtitles=subs.ass:fontsdir=/tmp/font[bg];[bg][2]overlay=10:10:format=auto,format=yuv420p" -t 10 output.mp4
  • Using color filter for synthetic inputs (the red, green, and blue boxes).
  • overlay filter to place the green and blue boxes.
  • subtitles filter to place subtitles.
  • format filter is used to prevent chroma-subsampling induced blurryness and to enable alpha/transparency for blue box.
  • fontsdir option was used in this example to locate external fonts. fontsdir can be omitted if you want to use fonts already installed in your system.

subs.ass for above example

[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: None

[Aegisub Project Garbage]
Last Style Storage: Default

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Bradley Hand,28,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,7,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,Line 1: Bradley Hand font\N{\fnComic Sans MS}Line 2: Comic Sans MS font{\fn}\NLine 3: Bradley Hand font
  • Subtitles were positioned with Alignment option in ASS file.
  • Default font was set with Fontname option in ASS file.
  • Font for Line 2 was set using \fn override tag.


来源:https://stackoverflow.com/questions/64927560/overlay-in-ffmpeg-with-subtitle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!