ffmpeg 字幕过滤器输入垫错误

ffmpeg 字幕过滤器输入垫错误

我做错了什么?我花了几个小时尝试让它工作。我知道这与字幕过滤器有关,但无法弄清楚。

如果我运行示例命令(例如下面的命令),它可以正常工作:

ffmpeg -y -i 5e47a1be4df117b7f79596dda7987c45.mp4 -filter_complex "subtitles=intro.ass:fontsdir=../../preview/fonts[subtitle];[0:v][subtitle]overlay" test.mp4

介绍下面的内容

[Script Info]
PlayResX: 878
PlayResY: 494
WrapStyle: 1

[V4+ Styles]
Format: Name, Fontname, Alignment, MarginL, MarginR
Style: introductory_text, Tangerine, 5, 350, 50

[Events]
Format: Start, End, Style, Text
Dialogue: 0:00:05.00, 0:00:21.00, introductory_text, {\fad(1000,0)}{\fnTangerine}{\fs46}{\c&FFFFFF&}Main text here, could be long enough to split in multiple lines{\fn}\N{\fnPontano Sans}{\fs40}{\c&FFFFFF&}This is the title that can be long enough, too{\fn}\N{\fnGreat Vibes}{\fs30}{\c&HFFFFFF&}A subtitle here, can be long, also{\fn}

无效的命令

cd ../../assets/20210831182306_699_3579_intro_sWZTo82cXR/; time ffmpeg -hide_banner -y -i 5e47a1be4df117b7f79596dda7987c45.mp4 -i 07201487ede265cdea98d02930cd90dd.jpg.png -i ../../preview/helper-videos/bokeh.mp4 -i 1629885277.mp3 -preset ultrafast -crf 18 -filter_complex " [0:v]scale=878:494:force_original_aspect_ratio=decrease,pad=878:494:(ow-iw)/2:(oh-ih)/2,setsar=1,format=yuva420p[video]; [video]fade=in :0 :25[video]; [2:v]scale=1756:988:force_original_aspect_ratio=increase,format=rgba,colorchannelmixer=aa=0.2[motionOverlay];[video][motionOverlay]overlay[video]; [video]drawbox= x=0 :y=0 :w=iw :h=ih :[email protected] :t='fill' :enable='between(t,3,21)'[video]; [1:v]scale=-2:247:force_original_aspect_ratio=increase,format=yuva420p[scaledCoverPhoto]; [video][scaledCoverPhoto]overlay=:x=w/2:y=(H-h)/2:enable='between(t,4,21)'[videofinal]; subtitles=intro.ass:fontsdir=../../preview/fonts[subtitle];[videofinal][subtitle]overlay, format=yuv420p, scale=-2:494 " -shortest -map 3:a out.mp4

下面的命令日志

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '5e47a1be4df117b7f79596dda7987c45.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf58.29.100
media_type      : 0
hd_video        : 0
Duration: 00:00:21.29, start: 0.000000, bitrate: 1139 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 878x494 [SAR 3952:3951 DAR 16:9], 1136 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name    : VideoHandler
vendor_id       : [0][0][0][0]
Input #1, png_pipe, from '07201487ede265cdea98d02930cd90dd.jpg.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgb24(pc), 431x514 [SAR 3779:3779 DAR 431:514], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '../../preview/helper-videos/bokeh.mp4':
Metadata:
major_brand     : mp42
minor_version   : 0
compatible_brands: isommp42
creation_time   : 2012-03-21T12:18:56.000000Z
Duration: 00:00:07.00, start: 0.000000, bitrate: 1060 kb/s
Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1152x720, 1054 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc (default)
Metadata:
creation_time   : 1970-01-01T00:00:00.000000Z
handler_name    : VideoHandler
vendor_id       : [0][0][0][0]
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 3 kb/s (default)
Metadata:
creation_time   : 2012-03-21T12:18:56.000000Z
handler_name    : IsoMedia File Produced by Google, 5-11-2011
vendor_id       : [0][0][0][0]
Input #3, mp3, from '1629885277.mp3':
Metadata:
title           : The Gift of Love
TLEN            : 228773
publisher       : Musical Reflections, Inc.
genre           : Instrumental
album           : Love's Journey
album_artist    : Tami Briggs
track           : 7
artist          : Tami Briggs
date            : 1999-00-00
encoder         : Lavf58.29.100
id3v2_priv.WM/MediaClassPrimaryID: \xbc}`\xd1#\xe3\xe2K\x86\xa1H\xa4*(D\x1e
id3v2_priv.WM/MediaClassSecondaryID: \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
id3v2_priv.WM/WMContentID: \xee\xb1,V\xa5H*A\x9c\x07\xbb/\xbb3\xc2\xba
id3v2_priv.WM/UniqueFileIdentifier: A\x00M\x00G\x00a\x00_\x00i\x00d\x00=\x00R\x00 \x00 \x00 \x007\x007\x003\x003\x008\x008\x00;\x00A\x00M\x00G\x00p\x00_\x00i\x00d\x00=\x00P\x00 \x00 \x00 \x007\x000\x007\x000\x009\x004\x00;\x00A\x00M\x00G\x00t\x00_\x00i\x00d\x00=\x00T\x00 \x00 \x007\x008\x00
id3v2_priv.WM/WMCollectionID: (\xc2\xd0\x91\x17\xa1rK\xa3\xfd\xea\xe6QBA\x81
id3v2_priv.WM/WMCollectionGroupID: (\xc2\xd0\x91\x17\xa1rK\xa3\xfd\xea\xe6QBA\x81
id3v2_priv.WM/Provider: A\x00M\x00G\x00\x00\x00
id3v2_priv.XMP  : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c014 79.156821, 2014/08/29-03:07:50        ">\x0a <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\x0a  <rdf
Duration: 00:03:44.21, start: 0.025057, bitrate: 128 kb/s
Stream #3:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder         : Lavc58.54
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] libass API version: 0x1501000
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] libass source: tarball: 0.15.1
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Shaper: FriBidi 1.0.10 (SIMPLE) HarfBuzz-ng 2.8.2 (COMPLEX)
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/quicksand-bold.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/fjallaone-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/signika-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/lato-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/philosopher-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/quicksand-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/gentiumbasic-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/mavenpro-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/comingsoon-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/overlock-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/tangerine-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/gentiumbasic-italic.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/alegreya-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/dancingscript-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/courgette-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/opensans-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/lora-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/pontanosans-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/cambo-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/cantataone-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Loading font file '../../preview/fonts/greatvibes-regular.ttf'
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Using font provider coretext
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Track has custom format line(s). 'ScaledBorderAndShadow' will default to 'yes'.
[Parsed_subtitles_13 @ 0x7f9b0cd17d80] Track has custom format line(s). 'ScaledBorderAndShadow' will default to 'yes'.
Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_subtitles_13

real    0m0.093s
user    0m0.063s
sys 0m0.024s

答案1

字幕过滤器会覆盖(“刻录”)字幕本身 - 无需将其输出覆盖到视频上。因此,它需要视频流作为输入。

你的过滤图应该以如下方式结束,

[video][scaledCoverPhoto]overlay=:x=w/2:y=(H-h)/2:enable='between(t,4,21)',subtitles=intro.ass:fontsdir=../../preview/fonts,format=yuv420p,scale=-2:494

相关内容