FFMPEG 在 filter_complex 链中显示具有特定持续时间的图像

FFMPEG show an Image with specific duration in filter_complex chain

我无法在 filter_complex 中显示具有特定持续时间的图像。

我必须使用 filter_complex,出现错误:“没有这样的过滤器:'duration'”

那么我需要使用哪个过滤器?

ffmpeg \
    -i "music.mp3" \
    -i "01.mp4" \
    -i "02.jpg" \
    -i "03.mp4" \
    -i "04.jpg" \
    -i "05.mp4" \
    -filter_complex " \
        [1:v]scale=300:400,trim=0:2,setpts=PTS-STARTPTS[v1]; \
        // Correct filter needed here: \
        [2:v]scale=300:400,duration=2,setpts=PTS-STARTPTS[v2]; \
        [3:v]scale=300:400,trim=4:6,setpts=PTS-STARTPTS[v3]; \
        // And here:
        [4:v]scale=300:400,duration=2,setpts=PTS-STARTPTS[v4]; \
        [5:v]scale=300:400,trim=8:10,setpts=PTS-STARTPTS[v5]; \
        [v1][v2][v3][v4][v5]concat=n=5:v=1:a=0[out] \
    " \
    -map "[out]" -map "0:a" -t "12" -c:v "libx264" -pix_fmt "yuv420p" -s "300x400" output.mp4

对于单个图像输入,使用 -t-loop 选项并删除不存在的 duration 和现有的 setpts 过滤器。

ffmpeg \
    -i "music.mp3" \
    -i "01.mp4" \
    -loop 1 -t 2 -i "02.jpg" \
    -i "03.mp4" \
    -loop 1 -t 2 -i "04.jpg" \
    -i "05.mp4" \
    -filter_complex " \
        [1:v]scale=300:400,trim=0:2,setpts=PTS-STARTPTS[v1]; \
        [2:v]scale=300:400[v2]; \
        [3:v]scale=300:400,trim=4:6,setpts=PTS-STARTPTS[v3]; \
        [4:v]scale=300:400[v4]; \
        [5:v]scale=300:400,trim=8:10,setpts=PTS-STARTPTS[v5]; \
        [v1][v2][v3][v4][v5]concat=n=5:v=1:a=0[out] \
    " \
    -map "[out]" -map "0:a" -t "12" -c:v "libx264" -pix_fmt "yuv420p" -s "300x400" output.mp4

与您的 Q 无关,但所有输入都应具有相同的纵横比,因此最好在所有 scale 之后添加 setsar=1