Body: <p>I've concat or joined four video files using <strong>ffmpeg concat demuxer</strong> The video has no problem. But on audio side I am greeted with a bunch of error when I tried re encoding the final video. Here is the console output:</p>
  
  <pre><code>Output #0, matroska, to '../videos/nnnnc.mkv':
    Metadata:
      encoder         : Lavf58.42.101
      Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 1k tbn, 23.98 tbc (default)
      Metadata:
        DURATION        : 02:35:10.922000000
        encoder         : Lavc58.80.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
      Stream #0:1: Audio: aac (libfdk_aac) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, s16, 139 kb/s (default)
      Metadata:
        DURATION        : 02:35:10.929000000
        encoder         : Lavc58.80.100 libfdk_aac
      Stream #0:2: Subtitle: subrip (default)
      Metadata:
        DURATION        : 02:35:10.920000000
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 108.2kbits/s dup=0 drop=2 speed=6.21x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 678.3kbits/s dup=0 drop=2 speed=5.96x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 771.3kbits/s dup=0 drop=2 speed=5.87x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 693.0kbits/s dup=0 drop=2 speed=5.89x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocated
  Error while decoding stream #0:1: Invalid data found when processing input
  </code></pre>
  
  <p><strong>ffprobe</strong> output of source 1</p>
  
  <pre><code>[STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=unknown
  color_transfer=unknown
  color_primaries=unknown
  chroma_location=unspecified
  field_order=progressive
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=105
  start_time=0.105000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 libx265
  TAG:DURATION=00:00:03.108000000
  [/STREAM]
  [STREAM]
  index=1
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=3108
  duration=3.108000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 subrip
  TAG:DURATION=00:00:03.105000000
  [/STREAM]
  [STREAM]
  index=2
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 libfdk_aac
  TAG:DURATION=00:00:03.105000000
  [/STREAM]
  </code></pre>
  
  <p><strong>ffprobe</strong> output of source 2,3,4 (all are same source)</p>
  
  <pre><code>[STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=bt709
  color_transfer=bt709
  color_primaries=bt709
  chroma_location=unspecified
  field_order=unknown
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=7
  start_time=0.007000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=651629
  TAG:BPS-eng=651629
  TAG:DURATION=00:51:39.472000000
  TAG:DURATION-eng=00:51:39.472000000
  TAG:NUMBER_OF_FRAMES=74313
  TAG:NUMBER_OF_FRAMES-eng=74313
  TAG:NUMBER_OF_BYTES=252463300
  TAG:NUMBER_OF_BYTES-eng=252463300
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  [STREAM]
  index=1
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=3
  start_time=0.003000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=64000
  TAG:BPS-eng=64000
  TAG:DURATION=00:51:39.605000000
  TAG:DURATION-eng=00:51:39.605000000
  TAG:NUMBER_OF_FRAMES=72647
  TAG:NUMBER_OF_FRAMES-eng=72647
  TAG:NUMBER_OF_BYTES=24796844
  TAG:NUMBER_OF_BYTES-eng=24796844
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  [STREAM]
  index=2
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=3
  start_time=0.003000
  duration_ts=3099605
  duration=3099.605000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=65
  TAG:BPS-eng=65
  TAG:DURATION=00:49:21.500000000
  TAG:DURATION-eng=00:49:21.500000000
  TAG:NUMBER_OF_FRAMES=777
  TAG:NUMBER_OF_FRAMES-eng=777
  TAG:NUMBER_OF_BYTES=24256
  TAG:NUMBER_OF_BYTES-eng=24256
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  </code></pre>
  
  <p><strong>ffprobe</strong> output of the joined video</p>
  
  <pre><code>[STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=unknown
  color_transfer=unknown
  color_primaries=unknown
  chroma_location=unspecified
  field_order=progressive
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=105
  start_time=0.105000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.922000000
  [/STREAM]
  [STREAM]
  index=1
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.929000000
  [/STREAM]
  [STREAM]
  index=2
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=9310929
  duration=9310.929000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.920000000
  [/STREAM]
  </code></pre>
  
  <p>The source 1 is generated via the following command to match source <strong>2,3,4</strong></p>
  
  <pre><code>ffmpeg -loop 1 -i image.png -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i sub.srt -map 0:v $amap $smap -t 3 -vf 'scale=1280x720,fade=type=in:duration=1,fade=type=out:duration=1:start_time=2' -r 23.98 -crf 22 -c:v hevc -pix_fmt yuv420p -c:a libfdk_aac -profile:a 4 -ac 2 -ar 48000 -c:s copy wmv1.mkv"
  </code></pre>
  
  <p>The <code>$amap $smap</code> are PHP variable to match <strong>2,3,4</strong> configuration.</p>
  
  <p>If I join video <strong>2,3,4</strong> without video <strong>1</strong> the output is fine. There is no error in encoding.</p>
  
  <p>But when I include video <strong>1</strong> the encoding goes crazy by spamming my console with errors. No matter what I try or how differently I try. Outcome is same. </p>
  
  <p>Concat demuxer command</p>
  
  <p><code>ffmpeg -safe 0 -f concat -i list.txt -c copy -c:s copy ../videos/nnnnc.mkv</code> 
   and list.txt</p>
  
  <pre><code>file 'source1.mkv'
  duration 3
  
  file 'source2.mkv'
  duration 3099.6
  
  file 'source2.mkv'
  duration 3099.6
  
  file 'source2.mkv'
  duration 3099.6
  </code></pre>
  
  <p><strong><em>What am I doing wrong here?</em></strong> </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-24T04:09:13.743Z
Comments.Text: @llogan `ffmpeg -safe 0 -f concat -i list.txt -c copy -c:s copy out.mkv`
Comments.UserDisplayName: Ananta Prodhan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-24T18:51:50.177Z
Comments.Text: The order of your streams do not match. Try `ffmpeg -loop 1 -framerate 24000/1001 -i image.png -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i sub.srt -filter_complex '[0:v]scale=1280x720,fade=type=in:duration=1,fade=type=out:duration=1:start_time=2,format=yuv420p[v]' -map "[v]" -map 1 -map 2 -crf 22 -c:v hevc -c:a libfdk_aac -profile:a 4 -c:s copy -t 3 wmv1.mkv"`
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-25T07:01:39.037Z
Comments.Text: @llogan I didn't know that the ordering is also important. I'll try this now
Comments.UserDisplayName: Ananta Prodhan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-27T11:45:47.120Z
Comments.Text: I have tried that. But same result as before. It seems the generated audio is not identical to the other audios. I have tried many possible combination now and no luck :(
Comments.UserDisplayName: Ananta Prodhan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-27T18:11:51.110Z
Comments.Text: Can you provide a link to a small sample file that is similar to source 2,3,4?
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-28T05:49:05.667Z
Comments.Text: @llogan https://letsupload.co/Rhv7/out2.2ch.mkv (stereo)
  https://letsupload.co/Rhv8/out2.5.1ch.mkv (5.1)
    2 minutes file
Comments.UserDisplayName: Ananta Prodhan
Tags: <video><ffmpeg><video-recording>
Title: Audio is corrupted after joining videos with ffmpeg concat demuxer
UserDisplayName: Ananta Prodhan
ThreadText: # Audio is corrupted after joining videos with ffmpeg concat demuxer
  
  (Asked by: username_0 on 2020-04-23)
  
  I've concat or joined four video files using **ffmpeg concat demuxer** The video has no problem. But on audio side I am greeted with a bunch of error when I tried re encoding the final video. Here is the console output:
  
  ```
  Output #0, matroska, to '../videos/nnnnc.mkv':
    Metadata:
      encoder         : Lavf58.42.101
      Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 1k tbn, 23.98 tbc (default)
      Metadata:
        DURATION        : 02:35:10.922000000
        encoder         : Lavc58.80.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
      Stream #0:1: Audio: aac (libfdk_aac) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, s16, 139 kb/s (default)
      Metadata:
        DURATION        : 02:35:10.929000000
        encoder         : Lavc58.80.100 libfdk_aac
      Stream #0:2: Subtitle: subrip (default)
      Metadata:
        DURATION        : 02:35:10.920000000
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 108.2kbits/s dup=0 drop=2 speed=6.21x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 678.3kbits/s dup=0 drop=2 speed=5.96x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 771.3kbits/s dup=0 drop=2 speed=5.87x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocatedbitrate= 693.0kbits/s dup=0 drop=2 speed=5.89x    
  Error while decoding stream #0:1: Invalid data found when processing input
  [aac @ 0x5653edc94b00] channel element 2.13 is not allocated
  Error while decoding stream #0:1: Invalid data found when processing input
  
  ```
  
  **ffprobe** output of source 1
  
  ```
  [STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=unknown
  color_transfer=unknown
  color_primaries=unknown
  chroma_location=unspecified
  field_order=progressive
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=105
  start_time=0.105000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 libx265
  TAG:DURATION=00:00:03.108000000
  [/STREAM]
  [STREAM]
  index=1
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=3108
  duration=3.108000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 subrip
  TAG:DURATION=00:00:03.105000000
  [/STREAM]
  [STREAM]
  index=2
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:ENCODER=Lavc58.80.100 libfdk_aac
  TAG:DURATION=00:00:03.105000000
  [/STREAM]
  
  ```
  
  **ffprobe** output of source 2,3,4 (all are same source)
  
  ```
  [STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=bt709
  color_transfer=bt709
  color_primaries=bt709
  chroma_location=unspecified
  field_order=unknown
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=7
  start_time=0.007000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=651629
  TAG:BPS-eng=651629
  TAG:DURATION=00:51:39.472000000
  TAG:DURATION-eng=00:51:39.472000000
  TAG:NUMBER_OF_FRAMES=74313
  TAG:NUMBER_OF_FRAMES-eng=74313
  TAG:NUMBER_OF_BYTES=252463300
  TAG:NUMBER_OF_BYTES-eng=252463300
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  [STREAM]
  index=1
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=3
  start_time=0.003000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=64000
  TAG:BPS-eng=64000
  TAG:DURATION=00:51:39.605000000
  TAG:DURATION-eng=00:51:39.605000000
  TAG:NUMBER_OF_FRAMES=72647
  TAG:NUMBER_OF_FRAMES-eng=72647
  TAG:NUMBER_OF_BYTES=24796844
  TAG:NUMBER_OF_BYTES-eng=24796844
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  [STREAM]
  index=2
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=3
  start_time=0.003000
  duration_ts=3099605
  duration=3099.605000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:BPS=65
  TAG:BPS-eng=65
  TAG:DURATION=00:49:21.500000000
  TAG:DURATION-eng=00:49:21.500000000
  TAG:NUMBER_OF_FRAMES=777
  TAG:NUMBER_OF_FRAMES-eng=777
  TAG:NUMBER_OF_BYTES=24256
  TAG:NUMBER_OF_BYTES-eng=24256
  TAG:_STATISTICS_WRITING_APP=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
  TAG:_STATISTICS_WRITING_DATE_UTC=2018-09-07 09:36:09
  TAG:_STATISTICS_WRITING_DATE_UTC-eng=2018-09-07 09:36:09
  TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  [/STREAM]
  
  ```
  
  **ffprobe** output of the joined video
  
  ```
  [STREAM]
  index=0
  codec_name=hevc
  codec_long_name=unknown
  profile=1
  codec_type=video
  codec_time_base=1001/24000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=1280
  height=720
  coded_width=1280
  coded_height=720
  has_b_frames=2
  sample_aspect_ratio=1:1
  display_aspect_ratio=16:9
  pix_fmt=yuv420p
  level=93
  color_range=tv
  color_space=unknown
  color_transfer=unknown
  color_primaries=unknown
  chroma_location=unspecified
  field_order=progressive
  timecode=N/A
  refs=1
  id=N/A
  r_frame_rate=24000/1001
  avg_frame_rate=24000/1001
  time_base=1/1000
  start_pts=105
  start_time=0.105000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.922000000
  [/STREAM]
  [STREAM]
  index=1
  codec_name=aac
  codec_long_name=unknown
  profile=4
  codec_type=audio
  codec_time_base=1/48000
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  sample_fmt=fltp
  sample_rate=48000
  channels=2
  channel_layout=stereo
  bits_per_sample=0
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=N/A
  duration=N/A
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.929000000
  [/STREAM]
  [STREAM]
  index=2
  codec_name=subrip
  codec_long_name=unknown
  profile=unknown
  codec_type=subtitle
  codec_time_base=0/1
  codec_tag_string=[0][0][0][0]
  codec_tag=0x0000
  width=N/A
  height=N/A
  id=N/A
  r_frame_rate=0/0
  avg_frame_rate=0/0
  time_base=1/1000
  start_pts=0
  start_time=0.000000
  duration_ts=9310929
  duration=9310.929000
  bit_rate=N/A
  max_bit_rate=N/A
  bits_per_raw_sample=N/A
  nb_frames=N/A
  nb_read_frames=N/A
  nb_read_packets=N/A
  DISPOSITION:default=1
  DISPOSITION:dub=0
  DISPOSITION:original=0
  DISPOSITION:comment=0
  DISPOSITION:lyrics=0
  DISPOSITION:karaoke=0
  DISPOSITION:forced=0
  DISPOSITION:hearing_impaired=0
  DISPOSITION:visual_impaired=0
  DISPOSITION:clean_effects=0
  DISPOSITION:attached_pic=0
  DISPOSITION:timed_thumbnails=0
  TAG:DURATION=02:35:10.920000000
  [/STREAM]
  
  ```
  
  The source 1 is generated via the following command to match source **2,3,4**
  
  ```
  ffmpeg -loop 1 -i image.png -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i sub.srt -map 0:v $amap $smap -t 3 -vf 'scale=1280x720,fade=type=in:duration=1,fade=type=out:duration=1:start_time=2' -r 23.98 -crf 22 -c:v hevc -pix_fmt yuv420p -c:a libfdk_aac -profile:a 4 -ac 2 -ar 48000 -c:s copy wmv1.mkv"
  
  ```
  
  The `$amap $smap` are PHP variable to match **2,3,4** configuration.
  
  If I join video **2,3,4** without video **1** the output is fine. There is no error in encoding.
  
  But when I include video **1** the encoding goes crazy by spamming my console with errors. No matter what I try or how differently I try. Outcome is same.
  
  Concat demuxer command
  
  `ffmpeg -safe 0 -f concat -i list.txt -c copy -c:s copy ../videos/nnnnc.mkv`
  and list.txt
  
  ```
  file 'source1.mkv'
  duration 3
  
  file 'source2.mkv'
  duration 3099.6
  
  file 'source2.mkv'
  duration 3099.6
  
  file 'source2.mkv'
  duration 3099.6
  
  ```
  
  ***What am I doing wrong here?***
  
  **Tags:** video, ffmpeg, video-recording
  
  > **Comments:**
  > **username_0**: @username_1 `ffmpeg -safe 0 -f concat -i list.txt -c copy -c:s copy out.mkv`  
  > **username_1**: The order of your streams do not match. Try `ffmpeg -loop 1 -framerate 24000/1001 -i image.png -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i sub.srt -filter_complex '[0:v]scale=1280x720,fade=type=in:duration=1,fade=type=out:duration=1:start_time=2,format=yuv420p[v]' -map "[v]" -map 1 -map 2 -crf 22 -c:v hevc -c:a libfdk_aac -profile:a 4 -c:s copy -t 3 wmv1.mkv"`  
  > **username_0**: @username_1 I didn't know that the ordering is also important. I'll try this now  
  > **username_0**: I have tried that. But same result as before. It seems the generated audio is not identical to the other audios. I have tried many possible combination now and no luck :(  
  > **username_1**: Can you provide a link to a small sample file that is similar to source 2,3,4?  
  > **username_0**: @username_1 https://letsupload.co/Rhv7/out2.2ch.mkv (stereo) https://letsupload.co/Rhv8/out2.5.1ch.mkv (5.1)   2 minutes file  
  
  ---
  
  ## 0 answers
  
  