title: how to solve ffmpeg video merging complain about parameters mismatching
body: <p>I'm trying to concatenate an intro video to a main video. Here's my command:</p>
  
  <pre><code>ffmpeg -i C:\Temp\intro.mp4 -i C:\Temp\main.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" C:\Temp\output.mp4
  </code></pre>
  
  <p>When I run this command in cmd, I get the following error:</p>
  
  <pre><code>ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 9.2.1 (GCC) 20190918
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
    libavutil      56. 35.100 / 56. 35.100
    libavcodec     58. 58.101 / 58. 58.101
    libavformat    58. 33.100 / 58. 33.100
    libavdevice    58.  9.100 / 58.  9.100
    libavfilter     7. 58.102 /  7. 58.102
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      creation_time   : 2019-09-21T09:23:34.000000Z
    Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
      Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
      Metadata:
        creation_time   : 2019-09-21T09:23:34.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : AVC Coding
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
      Metadata:
        creation_time   : 2019-09-21T09:23:34.000000Z
        handler_name    : #Mainconcept MP4 Sound Media Handler
  Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.40.101
    Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
      Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Stream mapping:
    Stream #0:0 (h264) -&gt; concat:in0:v0
    Stream #0:1 (aac) -&gt; concat:in0:a0
    Stream #1:0 (h264) -&gt; concat:in1:v0
    Stream #1:1 (aac) -&gt; concat:in1:a0
    concat:out:v0 -&gt; Stream #0:0 (libx264)
    concat:out:a0 -&gt; Stream #0:1 (aac)
  Press [q] to stop, [?] for help
  [Parsed_concat_0 @ 0000018168eedec0] Input link in0:v0 parameters (size 640x640, SAR 1:1) do not match the corresponding output link in0:v0 parameters (960x540, SAR 1:1)
  [Parsed_concat_0 @ 0000018168eedec0] Failed to configure output pad on Parsed_concat_0
  Error reinitializing filters!
  Failed to inject frame into filter network: Invalid argument
  Error while processing the decoded data for stream #1:0
  Conversion failed!
  </code></pre>
  
  <p>I'm not a video ninja. I know parameters are different, but I have no idea after hours of search on how to solve this. A lot of online video services concatenate these two videos and give me a reasonable result. They have a GUI though. I need to do it in code, so that I can automate it.</p>
  
  <p>How can I solve these errors?</p>
  
  <p><strong>Update:</strong> This is the second error:</p>
  
  <pre><code>ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 9.2.1 (GCC) 20190918
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
    libavutil      56. 35.100 / 56. 35.100
    libavcodec     58. 58.101 / 58. 58.101
    libavformat    58. 33.100 / 58. 33.100
    libavdevice    58.  9.100 / 58.  9.100
    libavfilter     7. 58.102 /  7. 58.102
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      creation_time   : 2019-09-21T09:23:34.000000Z
    Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
      Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
      Metadata:
        creation_time   : 2019-09-21T09:23:34.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : AVC Coding
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
      Metadata:
        creation_time   : 2019-09-21T09:23:34.000000Z
        handler_name    : #Mainconcept MP4 Sound Media Handler
  Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.40.101
    Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
      Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  File 'C:\Temp\output.mp4' already exists. Overwrite ? [y/N] Y
  Stream mapping:
    Stream #0:0 (h264) -&gt; scale
    Stream #0:1 (aac) -&gt; concat:in0:a0
    Stream #1:0 (h264) -&gt; concat:in1:v0
    Stream #1:1 (aac) -&gt; concat:in1:a0
    concat:out:v0 -&gt; Stream #0:0 (libx264)
    concat:out:a0 -&gt; Stream #0:1 (aac)
  Press [q] to stop, [?] for help
  [mp4 @ 000002f17869d7c0] Frame rate very high for a muxer not efficiently supporting it.
  Please consider specifying a lower framerate, a different muxer or -vsync 2
  [libx264 @ 000002f178acfec0] using SAR=1/1
  [libx264 @ 000002f178acfec0] MB rate (1600000000) &gt; level limit (16711680)
  [libx264 @ 000002f178acfec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 000002f178acfec0] profile High, level 6.2, 4:2:0, 8-bit
  [libx264 @ 000002f178acfec0] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  More than 1000 frames duplicated
  Too many packets buffered for output stream 0:0.
  [libx264 @ 000002f178acfec0] frame I:1     Avg QP:16.45  size:  4679
  [libx264 @ 000002f178acfec0] frame P:32    Avg QP:14.16  size:    33
  [libx264 @ 000002f178acfec0] frame B:96    Avg QP:17.67  size:    30
  [libx264 @ 000002f178acfec0] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
  [libx264 @ 000002f178acfec0] mb I  I16..4: 58.1% 34.8%  7.1%
  [libx264 @ 000002f178acfec0] mb P  I16..4:  0.1%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:99.9%
  [libx264 @ 000002f178acfec0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.8%  0.0%  0.0%  direct: 0.0%  skip:99.2%  L0: 0.0% L1:100.0% BI: 0.0%
  [libx264 @ 000002f178acfec0] 8x8 transform intra:33.8%
  [libx264 @ 000002f178acfec0] coded y,uvDC,uvAC intra: 4.6% 8.2% 7.3% inter: 0.0% 0.0% 0.0%
  [libx264 @ 000002f178acfec0] i16 v,h,dc,p: 74% 22%  5%  0%
  [libx264 @ 000002f178acfec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  1% 16% 83%  0%  0%  0%  0%  0%  0%
  [libx264 @ 000002f178acfec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 17% 26%  7%  5%  5%  5%  6%  5%
  [libx264 @ 000002f178acfec0] i8c dc,h,v,p: 93%  3%  3%  1%
  [libx264 @ 000002f178acfec0] Weighted P-Frames: Y:0.0% UV:0.0%
  [libx264 @ 000002f178acfec0] ref P L0: 62.5% 37.5%
  [libx264 @ 000002f178acfec0] ref B L1: 99.8%  0.2%
  [libx264 @ 000002f178acfec0] kb/s:535069.75
  Conversion failed!
  </code></pre>