无需使用单独的命令即可对 filter_complex 生成的输出进行修剪

无需使用单独的命令即可对 filter_complex 生成的输出进行修剪

我有一个过滤器复合表达式,它接受 4 个输入视频并将它们组合到屏幕的 4 个角落,并在每个视频的特定开始时间同步

ffmpeg \
    -i first_vid.mkv \
    -i second_vid.mp4 \
    -i third_vid.mkv \
    -i fourth_vid.mkv  \
    -filter_complex \
        "nullsrc=size=1280x720 [base]; \
        [0:v] \
            trim=start=40,\
            setpts=PTS-STARTPTS,\
            scale=640x360,\
            drawtext=fontfile=/Users/vr/Downloads/gameplay_vids/generated/control-freak-font/CONTF___.ttf\
            :text='one'\
            :fontsize=32\
            :fontcolor=0xFFFFFF\
            :alpha='if(lt(t,30),0,if(lt(t,35),(t-30)/5,if(lt(t,65),1,if(lt(t,70),(5-(t-65))/5,0))))'\
            :x=w-text_w-12\
            :y=h-text_h-12 [upperleft];\
        [1:v] \
            trim=start=35.05, \
            setpts=PTS-STARTPTS, \
            scale=640x360, \
            drawtext=fontfile=/Users/vr/Downloads/gameplay_vids/generated/control-freak-font/CONTF___.ttf \
            :text='two' \
            :fontsize=32 \
            :fontcolor=0xFFFFFF \
            :alpha='if(lt(t,30),0,if(lt(t,35),(t-30)/5,if(lt(t,65),1,if(lt(t,70),(5-(t-65))/5,0))))' \
            :x=w-text_w-12 \
            :y=h-text_h-12 [upperright]; \
        [2:v] \
            trim=start=36.467, \
            setpts=PTS-STARTPTS, \
            scale=640x360, \
            drawtext=fontfile=/Users/vr/Downloads/gameplay_vids/generated/control-freak-font/CONTF___.ttf \
           :text='three' \
           :fontsize=32 \
           :fontcolor=0xFFFFFF \
           :alpha='if(lt(t,30),0,if(lt(t,35),(t-30)/5,if(lt(t,65),1,if(lt(t,70),(5-(t-65))/5,0))))' \
           :x=w-text_w-12 \
           :y=h-text_h-12 [lowerleft]; \
        [3:v] \
            trim=start=35.097, \
            setpts=PTS-STARTPTS, \
            scale=640x360, \
            drawtext=fontfile=/Users/vr/Downloads/gameplay_vids/generated/control-freak-font/CONTF___.ttf \
           :text='four' \
           :fontsize=32 \
           :fontcolor=0xFFFFFF \
           :alpha='if(lt(t,30),0,if(lt(t,35),(t-30)/5,if(lt(t,65),1,if(lt(t,70),(5-(t-65))/5,0))))' \
           :x=w-text_w-12 \
           :y=h-text_h-12 [lowerright];  \
        [2:a] \
           atrim=start=36.467, \
           asetpts=PTS-STARTPTS[outa]; \
           [base][upperleft] overlay=shortest=1 [tmp1]; \
           [tmp1][upperright] overlay=shortest=1:x=640 \
           [tmp2];[tmp2][lowerleft] overlay=shortest=1:y=360 \
           [tmp3];[tmp3][lowerright] overlay=shortest=1:x=640:y=360[v] \
    " -map "[v]" -map "[outa]" -c:v libx264 -shortest -ss 00:00 -to 9999 "output.mp4"
  • 我想删除输出视频 37:23 到 37:33 之间的部分
  • 有没有办法可以做到这一点,而不必编写单独的 ffmpeg 命令(例如管道或链或多个 filter_complex 表达式)?

答案1

要修剪指定的部分,您需要分割、修剪,然后连接这些部分。

[2:a] \
   atrim=start=36.467, \
   asetpts=PTS-STARTPTS, asplit=2 [apre][apost]; \
   [apre]atrim=0:2253[apre];[apost]atrim=2263,asetpts=PTS-STARTPTS[apost]; \

然后后来,

[tmp3][lowerright] overlay=shortest=1:x=640:y=360,split=2[vpre][vpost]; \
[vpre]trim=0:2253[vpre];[vpost]trim=2263,setpts=PTS-STARTPTS[vpost]; \
[vpre][apre][vpost][apost]concat=n=2:v=1:a=1[v][outa] \

相关内容