ffmpeg amix filter命令的执行永不停止

时间:2020-07-16 09:58:33

标签: ffmpeg android-ffmpeg

您好,我想使用ffmpeg来实现下图所示的功能:

Series.map

ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex 
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2]
 -map [tmp2] -c:v libx264 output.mp4

工作正常,但输出中缺少音频,因此我使用以下命令来混合输入视频的音频:

ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex 
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2];
[0:a][1:a][2:a]amix=inputs=3:duration=shortest[audio] 
-map [tmp2] -map [audio] -c:v libx264 output.mp4

我不知道发生了什么,但是执行从未停止。它一直在继续。我以为输入音频的采样率和声道类型不匹配,所以我尝试如下:

ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex 
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2];
[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio0];
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio1];
[2:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio2];
[audio0][audio1][audio2]amix=inputs=3:duration=shortest[audio] 
-map [tmp2] -map [audio] -c:v libx264 output.mp4

,但结果相同。执行永不停止。我认为音频处理有些问题。同样,目前,如果我删除音频部分而仅输出视频,则在视频最短的时间结束时停止输出视频。我希望输出视频的长度应最长。短片应显示其最后一帧,直到最长的视频结束。有什么帮助吗?

PS:控制台日志:

ffmpeg version 3.3.4
     Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9 (GCC) 20140827 (prerelease)

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input1.mp4':
      Metadata:
        major_brand     : 
    isom
        minor_version   : 
    512
        compatible_brands: 
    isomiso2avc1mp41
        title           : 
    1946246598843281
        encoder         : 
    Lavf56.40.101
      Duration: 
    00:00:53.91
    , start: 
    -0.022109
    , bitrate: 
    256 kb/s
        Stream #0:0
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 400x304, 206 kb/s
    , 
    25 fps, 
    25 tbr, 
    90k tbn, 
    50 tbc
     (default)
        Metadata:
          handler_name    : 
    VideoHandler
        Stream #0:1
    (und)
    : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 47 kb/s
     (default)
        Metadata:
          handler_name    : 
    SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input2.mp4':
      Metadata:
        major_brand     : 
    isom
        minor_version   : 
    512
        compatible_brands: 
    isomiso2avc1mp41
title           : 
    617689615538740
        encoder         : 
    Lavf56.40.101
      Duration: 
    00:00:15.37
    , start: 
    -0.022109
    , bitrate: 
    392 kb/s
        Stream #1:0
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 400x400, 349 kb/s
    , 
    30 fps, 
    30 tbr, 
    90k tbn, 
    60 tbc
     (default)
        Metadata:
          handler_name    : 
    VideoHandler
        Stream #1:1
    (und)
    : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 47 kb/s
     (default)
        Metadata:
          handler_name    : 
    SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'input3.mp4':
      Metadata:
        major_brand     : 
    isom
        minor_version   : 
    512
        compatible_brands: 
    isomiso2avc1mp41
        encoder         : 
    Lavf57.25.100
      Duration: 
    00:00:05.97
    , start: 
    0.000000
    , bitrate: 
    770 kb/s
        Stream #2:0
    (und)
    : Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 128 kb/s
     (default)
        Metadata:
          handler_name    : 
    SoundHandler
        Stream #2:1
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 368x480, 608 kb/s
    , 
27.29 fps, 
    120 tbr, 
    12k tbn, 
    60 tbc
     (default)
        Metadata:
          handler_name    : 
    VideoHandler
Stream mapping:
      Stream #0:0 (h264) -> crop
      Stream #0:1 (aac) -> aformat
      Stream #1:0 (h264) -> crop
      Stream #1:1 (aac) -> aformat
      Stream #2:0 (aac) -> aformat
      Stream #2:1 (h264) -> crop
      overlay
     -> Stream #0:0 (libx264)
      amix
     -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help

0 个答案:

没有答案