如何避免 ffmpeg filter_complex 覆盖文件的 fps?
How to avoid ffmpeg filter_complex overriding the fps of a file?
我是 ffmpeg 的新手,如果这是一个简单的问题,我深表歉意。
我正在尝试使用以下脚本平铺四个 60fps 视频。它有效,但输出为 25fps。当我尝试使用 -r 将其强制恢复到 60 时,它看起来像 25fps 上采样到 60,在渲染时计算重复帧。
如何保留原始文件?
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "nullsrc=size=2800x2400 [base]; [0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D]; [base] [A] overlay=shortest=0 [tmp1]; [tmp1][B] overlay=shortest=0:y=600 [tmp2]; [tmp2][C] overlay=shortest=0:y=1200 [tmp3]; [tmp3][D] overlay=shortest=0:y=1800" -c:v libx264 quartetscore.mp4
设置 nullsrc 滤镜的帧速率(默认为 25 fps):
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "nullsrc=size=2800x2400:rate=60 [base]; [0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D]; [base] [A] overlay=shortest=0 [tmp1]; [tmp1][B] overlay=shortest=0:y=600 [tmp2]; [tmp2][C] overlay=shortest=0:y=1200 [tmp3]; [tmp3][D] overlay=shortest=0:y=1800" -c:v libx264 quartetscore.mp4
或者如果你想堆叠只使用 hstack 过滤器而不是 nullsrc 和多重叠加:
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "[0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D];[A][B][C][D]hstack=inputs=4" -c:v libx264 quartetscore.mp4
有关更多示例,请参阅 Vertically or horizontally stack (mosaic) several videos using ffmpeg?。
我是 ffmpeg 的新手,如果这是一个简单的问题,我深表歉意。
我正在尝试使用以下脚本平铺四个 60fps 视频。它有效,但输出为 25fps。当我尝试使用 -r 将其强制恢复到 60 时,它看起来像 25fps 上采样到 60,在渲染时计算重复帧。
如何保留原始文件?
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "nullsrc=size=2800x2400 [base]; [0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D]; [base] [A] overlay=shortest=0 [tmp1]; [tmp1][B] overlay=shortest=0:y=600 [tmp2]; [tmp2][C] overlay=shortest=0:y=1200 [tmp3]; [tmp3][D] overlay=shortest=0:y=1800" -c:v libx264 quartetscore.mp4
设置 nullsrc 滤镜的帧速率(默认为 25 fps):
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "nullsrc=size=2800x2400:rate=60 [base]; [0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D]; [base] [A] overlay=shortest=0 [tmp1]; [tmp1][B] overlay=shortest=0:y=600 [tmp2]; [tmp2][C] overlay=shortest=0:y=1200 [tmp3]; [tmp3][D] overlay=shortest=0:y=1800" -c:v libx264 quartetscore.mp4
或者如果你想堆叠只使用 hstack 过滤器而不是 nullsrc 和多重叠加:
ffmpeg -i vln1.mp4 -i vln2.mp4 -i vla.mp4 -i cello.mp4 -filter_complex "[0:v] setpts=PTS-STARTPTS, scale=2800x600 [A]; [1:v] setpts=PTS-STARTPTS, scale=2800x600 [B]; [2:v] setpts=PTS-STARTPTS, scale=2800x600 [C]; [3:v] setpts=PTS-STARTPTS, scale=2800x600 [D];[A][B][C][D]hstack=inputs=4" -c:v libx264 quartetscore.mp4
有关更多示例,请参阅 Vertically or horizontally stack (mosaic) several videos using ffmpeg?。