【问题标题】:How To Merge Vidoes Side by Side Using Ffmpeg Having Length More Than 2 Mins如何使用长度超过 2 分钟的 Ffmpeg 并排合并视频
【发布时间】:2019-12-31 07:54:03
【问题描述】:

我想合并两个长度为 2 分钟的 mp4 视频,我正在使用 FFMPEG 命令来合并视频,它需要太多的处理时间是否有任何其他方式或命令可以加快速度,我也在使用 -preset ultrafast,但它不起作用。

我在这里使用这个命令

ffmpegcommand = new String[]{"-y", "-i", recordedvideo, "-i", file.toString(),
                    "-filter_complex",
                    "[0:v:0]pad=iw*2:ih[bg];" +
                            "[bg][1:v:0]overlay=w;" +
                            "[1:a]volume=0.9[A];[0:a]aecho=1:0.1:" + Constant.DELAY + ":" + Constant.DECAY + "[B];[B]volume=70[C];[C][A]amix=inputs=2[a]",
                    "-map", "[a]",
                    "-c:v", "libx264", "-shortest", "-preset",
                    "ultrafast", path + time + ".mp4"};

【问题讨论】:

    标签: java android merge video-processing


    【解决方案1】:

    你的命令的输出是什么?

    您是否有与 ffmpeg 相关的错误消息?

    【讨论】:

    • 不只是为了减少处理时间需要太多时间吗?
    【解决方案2】:

    我编写这段代码是因为有时我想快速连接多个视频,而不必担心每个大小和格式。

    连接具有相同和不同编解码器/格式/大小/纵横比的文件。

    (确保每个视频都有音频!(必要时添加无声音频))

        # set video size of the output
    targetWidth=1024
    targetHeight=576
    
    #this scaler preserves the aspect ratio of the input video and adds padding if needed.
    #a video with a size of 720x576 will be upscaled to 1350x1080 to preserve the aspect ratio and padded left and right to achieve 1920x1080.
    smartScale="scale=iw*min($targetWidth/iw\,$targetHeight/ih):ih*min($targetWidth/iw\,$targetHeight/ih), pad=$targetWidth:$targetHeight:($targetWidth-iw*min($targetWidth/iw\,$targetHeight/ih))/2:($targetHeight-ih*min($targetWidth/iw\,$targetHeight/ih))/2:color=black, setdar=ratio=16/9, setfield=tff"
    
    # inputs are scaled to the same size and given a label
    # then they are concatenated
    ffmpeg \
    -i "01 video 1280x720.mov" \
    -i "02 video 720x576.mkv" \
    -i "03 video 1920x1080.mp4" \
    -filter_complex "\
    [0:v]${smartScale}[scaled_v0]; \
    [1:v]${smartScale}[scaled_v1]; \
    [2:v]${smartScale}[scaled_v2]; \
    [scaled_v0][0:a][scaled_v1][1:a][scaled_v2][2:a]\
    concat=n=3:v=1:a=1[v][a]" \
    -map "[v]" -map "[a]" -c:v libx264 -crf 23 -c:a aac concatenated.mkv
    

    我已经测试了很多次,效果很好。

    【讨论】:

    • @darke7 我有 2 分钟的视频需要多少处理时间,而合并几乎需要 2 分钟你呢?
    • @Muhammed Haroon 我已经连接了两个约 15 分钟的视频(1920x1080,AVC)。它以 2.6 倍的速度处理,大约 12 分钟。
    • @darke 同样是我的情况,它需要太多时间我有 2 分钟的视频,并且并排合并需要将近 1 到 2 分钟我只想在 12 到 20 秒内将它们合并为 smule应用程序在 smule 应用程序中进行合并需要几秒钟
    • @Muhammed Haroon 你需要在“video1”之后连接“video2”吗?还是您需要左侧的“video1”和右侧的“video2”?
    • @darke 是的,我想要两个并排的视频,一个在左边,另一个在右边
    猜你喜欢
    • 2021-11-20
    • 2017-08-09
    • 1970-01-01
    • 2018-04-23
    • 2019-03-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多