gpt4 book ai didi

ffmpeg - 并排加入视频

转载 作者:行者123 更新时间:2023-12-04 23:21:31 25 4
gpt4 key购买 nike

我需要并排加入两个 webm 视频,我一直在使用以下 ffmpeg 命令加入它们:

ffmpeg -i /client.webm -i /client2.webm -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 /combined.webm
但是,我有 2 个问题
  • 如果视频的尺寸或持续时间不同,这似乎无法正常工作,
  • 此外,它似乎非常缓慢且资源密集。

  • 我渴望任何解决方案,我很想知道是否有更好的命令行替代方案。

    最佳答案

    this doesn't seem to work properly if videos are of different dimensions or durations


    “似乎无法正常工作”并不能真正告诉我们太多信息,但如果高度不匹配,您应该会收到一个信息性错误,例如: Input 1 height 1080 does not match input 0 height 720.hstack 过滤器的每个输入必须具有相同的高度。 You can get height with ffprobe .然后使用 scale、scale2ref、pad 和/或crop filters使高度相同。
    至于持续时间,您可以使用 shortest hstack 中的选项以在最短输入终止时强制终止。也用通用 -shortest选项,以便音频与加入的视频持续时间相匹配。
    例子:
    ffmpeg -i /client.webm -i /client2.webm -filter_complex "[0:v]scale=-2:720[v0];[v0][1:v]hstack=inputs=2:shortest=1[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 -shortest /combined.webm

    moreover it seems extremely slow and resource-intensive.


    视频编码是资源密集型的。
    libvpx-vp9 是一个相对较慢的编码器。见 FFmpeg Wiki: VP9一些建议或使用不同的编码器。

    I'd love to know if there are any better command-line alternatives.


    如果您只想并排观看但不需要实际创建文件,那么只需使用播放器即可。
    看:
  • Multiple side-to-side video streams in one file without transcoding
  • MPV (FFmpeg) stack 2 videos and then crop output without re-encoding?
  • 关于ffmpeg - 并排加入视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65047578/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com