ffmpeg concat 过滤器正在丢弃第二个视频的第一秒

发布于 2025-01-11 07:22:25 字数 1031 浏览 0 评论 0原文

con.txt

file one.mp4
file two.mp4

该命令

ffmpeg -f concat -safe 0 -i con.txt out.mp4

生成的视频不包含 two.mp4 的第一秒。

ffprobe Two.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'two.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
  Duration: 00:00:15.20, start: 0.000000, bitrate: 1644 kb/s
  Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 428x640, 1644 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]

我在尝试另一种串联方法时遇到一个有趣的错误(顺便说一句,两个视频都没有音频)

ffmpeg -i one.mp4 -i Two.mp4 -filter_complex "[0:v] [ 1:v] concat=n=2:v=1:a=0 [v]" -map "[v]" out.mp4

输入链接 in0:v0 参数(大小 428x640,SAR 0:1)与相应的输出链接 in0:v0 参数(428x640,SAR 1576:1575)不匹配

如何将这两个视频按顺序连接在一起而不丢失任何帧?

con.txt

file one.mp4
file two.mp4

The command

ffmpeg -f concat -safe 0 -i con.txt out.mp4

produces a video that doesn't contain the first second of two.mp4.

ffprobe two.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'two.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
  Duration: 00:00:15.20, start: 0.000000, bitrate: 1644 kb/s
  Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 428x640, 1644 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]

I get an interesting error attempting another concatenation method (neither video has audio btw)

ffmpeg -i one.mp4 -i two.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1:a=0 [v]" -map "[v]" out.mp4

Input link in0:v0 parameters (size 428x640, SAR 0:1) do not match the corresponding output link in0:v0 parameters (428x640, SAR 1576:1575)

How can I join these two videos together sequentially without losing any frames from either?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

短暂陪伴 2025-01-18 07:22:25

concat 过滤器期望连接的流具有相同的属性(大小、样本宽高比 (SAR)、pix_fmt 等)。错误消息表明 SAR 不匹配。您可以在 concat 过滤器上游插入 setsar 过滤器来解决此问题。假设这些视频具有方形像素(1576:1575 非常接近 1:1),我们可以这样做:

ffmpeg -i one.mp4 -i two.mp4 \
  -filter_complex "[0:v]setsar=1:1[L0]; \
                   [1:v]setsar=1:1,fps=30[L1]; \
                   [L0][L1]concat=n=2:v=1:a=0 [v] " \
  -map "[v]" out.mp4

如果出现其他错误,则需要预先添加更多过滤器来调节流以相互匹配。

编辑:向第二个视频 (10 fps) 添加了 fps 过滤器以匹配第一个视频 (30 fps)

The concat filter expects the streams to be concatenated to have the identical properties (size, sample aspect ratio (SAR), pix_fmt, etc.). The error message is saying that SARs are not matching up. You can insert setsar filters upstream of concat filter to resolve this. Assuming these videos have square pixels (1576:1575 is pretty darn close to 1:1), we can do this:

ffmpeg -i one.mp4 -i two.mp4 \
  -filter_complex "[0:v]setsar=1:1[L0]; \
                   [1:v]setsar=1:1,fps=30[L1]; \
                   [L0][L1]concat=n=2:v=1:a=0 [v] " \
  -map "[v]" out.mp4

If you get other errors, you need to prepend more filters to condition your streams to match each other.

Edit: Added fps filter to the second video (10 fps) to match the first (30 fps)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文