Answers.Body: <p>Don't use the concat demuxer. Create a single ts file by concatenating the ts segments as a first step. Then run it through ffmpeg.</p>
  
  <p>i.e.
  <code>cat 1.ts 2.ts &gt;all.ts</code>
  <code>ffmpeg -i all.ts -c copy all.mp4</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-09T05:08:23.377Z
Answers.Text: I guess you mean concat protocol. I read that this method support only MPEG-1, MPEG-2 PS, DV containers. In my case, ts segments are h.264 container
Answers.UserDisplayName: nurmat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-09T05:23:15.217Z
Answers.Text: no, I mean exactly what I said (https://trac.ffmpeg.org/wiki/Concatenate#demuxer) h.264 is the codec, transport stream (ts) is the container. I don't know what you read, but you CAN concatenate ts segments.
Answers.UserDisplayName: SlimSCSI
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-09T06:31:25.220Z
Answers.Text: Yes, i got mixed up mp4 with h264. Your answer is incomplete a bit. I added -bsf:a aac_adtstoasc option and that's ok. [Here](http://ffmpeg.org/faq.html#Concatenating-using-the-concat-protocol-_0028file-level_0029) is another way of the concat protocol
Answers.UserDisplayName: nurmat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-08T17:48:32.733Z
Answers.LastActivityDate: 2016-12-08T17:48:32.733Z
Answers.UserDisplayName: SlimSCSI
Body: <p>I have downloaded segmented ts files, which i concatenate into mp4 file. The problem is that audio a bit faster than video progress. The problem is appeared when i re-convert concatenated mp4 file. How can i fix this audio issue?</p>
  
  <p>Concatenation ffmpeg command:</p>
  
  <pre><code>ffmpeg -f concat -i hls.txt -c copy -bsf:a aac_adtstoasc hls.mp4 1&gt; hls.log 2&gt;&amp;1
  </code></pre>
  
  <p>Some concatenation output </p>
  
  <pre><code>ffmpeg version N-76684-g1fe82ab Copyright (c) 2000-2015 the FFmpeg developers
    built with gcc 5.2.0 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
    libavutil      55.  6.100 / 55.  6.100
    libavcodec     57. 15.100 / 57. 15.100
    libavformat    57. 14.100 / 57. 14.100
    libavdevice    57.  0.100 / 57.  0.100
    libavfilter     6. 15.100 /  6. 15.100
    libswscale      4.  0.100 /  4.  0.100
    libswresample   2.  0.101 /  2.  0.101
    libpostproc    54.  0.100 / 54.  0.100
  [NULL @ 000000ebd70f13a0] start time for stream 2 is not set in estimate_timings_from_pts
  Input #0, concat, from 'hls.txt':
    Duration: N/A, start: 0.000000, bitrate: N/A
      Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 149 kb/s
      Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
  [mp4 @ 000000ebd7513aa0] Codec for stream 0 does not use global headers but container format requires global headers
  [mp4 @ 000000ebd7513aa0] Codec for stream 1 does not use global headers but container format requires global headers
  Output #0, mp4, to 'hls.mp4':
    Metadata:
      encoder         : Lavf57.14.100
      Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
      Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 149 kb/s
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (copy)
    Stream #0:1 -&gt; #0:1 (copy)
  Press [q] to stop, [?] for help
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
  ...
  [h264 @ 000000ebd789d720] decode_slice_header error
  [h264 @ 000000ebd789d720] no frame!
  [NULL @ 000000ebd789bbc0] start time for stream 2 is not set in estimate_timings_from_pts
  frame= 9321 fps=5550 q=-1.0 Lsize=   97452kB time=00:06:19.95 bitrate=2101.1kbits/s    
  video:90227kB audio:6888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.346746%
  </code></pre>
  
  <p>Here is my re-convert command:</p>
  
  <pre><code>ffmpeg -y -i hls.mp4 -i watermark.png -filter_complex "scale=-2:'min(720,ih)',overlay=(main_w-overlay_w)-40:(main_h-overlay_h)-30" -codec:v libx264 -profile:v high -level 3.1 -preset fast -maxrate 1946k -bufsize 2500k -c:a copy -crf 20 -pix_fmt yuv420p -movflags +faststart output.mp4 1&gt; output.log 2&gt;&amp;1
  </code></pre>
  
  <p>Some output log:</p>
  
  <pre><code>ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers
    built on Nov 16 2014 22:36:57 with gcc 4.8.2 (GCC)
    configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/man --docdir=/usr/doc/ffmpeg-2.4.3 --enable-gpl --enable-version3 --enable-avfilter --enable-avresample --enable-libass --enable-libdc1394 --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-postproc --enable-runtime-cpudetect --enable-vaapi --enable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --arch=x86_64 --enable-pic --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib64 -ldl -lssl -lcrypto -lz -lusb' --pkg-config-flags=--static
    libavutil      54.  7.100 / 54.  7.100
    libavcodec     56.  1.100 / 56.  1.100
    libavformat    56.  4.101 / 56.  4.101
    libavdevice    56.  0.100 / 56.  0.100
    libavfilter     5.  1.100 /  5.  1.100
    libavresample   2.  1.  0 /  2.  1.  0
    libswscale      3.  0.100 /  3.  0.100
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  0.100 / 53.  0.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hls.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf57.14.100
    Duration: 00:06:19.96, start: 0.000000, bitrate: 2101 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1946 kb/s, 24.54 fps, 50 tbr, 90k tbn, 50 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 148 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Input #1, png_pipe, from 'watermark.png':
    Duration: N/A, bitrate: N/A
      Stream #1:0: Video: png, rgba, 250x50, 25 tbr, 25 tbn, 25 tbc
  [libx264 @ 0x2316f40] using SAR=1/1
  [libx264 @ 0x2316f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
  [libx264 @ 0x2316f40] profile High, level 3.1
  [libx264 @ 0x2316f40] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=3 lookahead_threads=1 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1946 vbv_bufsize=2500 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'output.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.4.101
      Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, max. 1946 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
      Metadata:
        encoder         : Lavc56.1.100 libx264
      Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 148 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Stream mapping:
    Stream #0:0 (h264) -&gt; scale
    Stream #1:0 (png) -&gt; overlay:overlay
    overlay -&gt; Stream #0:0 (libx264)
    Stream #0:1 -&gt; #0:1 (copy)
  Press [q] to stop, [?] for help
  frame=   38 fps=0.0 q=25.0 size=       4kB time=00:00:01.65 bitrate=  17.4kbits/s dup=3 drop=0    
  frame=   50 fps= 46 q=25.0 size=      20kB time=00:00:02.14 bitrate=  76.7kbits/s dup=3 drop=0    
  frame=   58 fps= 35 q=25.0 size=      75kB time=00:00:02.44 bitrate= 249.9kbits/s dup=3 drop=0    
  ...
  frame= 9478 fps= 13 q=25.0 size=   94544kB time=00:06:19.26 bitrate=2042.1kbits/s dup=175 drop=0    
  [mp4 @ 0x2316160] Starting second pass: moving the moov atom to the beginning of the file
  frame= 9496 fps= 13 q=-1.0 Lsize=   94901kB time=00:06:19.95 bitrate=2046.1kbits/s dup=175 drop=0    
  video:87673kB audio:6888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.359540%
  [libx264 @ 0x2316f40] frame I:64    Avg QP:25.22  size: 53069
  [libx264 @ 0x2316f40] frame P:5242  Avg QP:27.77  size: 13431
  [libx264 @ 0x2316f40] frame B:4190  Avg QP:29.21  size:  3813
  [libx264 @ 0x2316f40] consecutive B-frames: 21.7% 52.4% 17.8%  8.0%
  [libx264 @ 0x2316f40] mb I  I16..4: 15.5% 61.0% 23.5%
  [libx264 @ 0x2316f40] mb P  I16..4:  5.6%  9.5%  1.3%  P16..4: 41.7%  8.8%  4.0%  0.0%  0.0%    skip:29.0%
  [libx264 @ 0x2316f40] mb B  I16..4:  1.9%  1.6%  0.1%  B16..8: 29.8%  3.9%  0.3%  direct: 3.5%  skip:59.0%  L0:39.2% L1:55.5% BI: 5.3%
  [libx264 @ 0x2316f40] 8x8 transform intra:56.1% inter:70.6%
  [libx264 @ 0x2316f40] coded y,uvDC,uvAC intra: 34.0% 52.1% 12.3% inter: 11.3% 12.9% 0.6%
  [libx264 @ 0x2316f40] i16 v,h,dc,p: 23% 48% 14% 16%
  [libx264 @ 0x2316f40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 30% 25%  3%  3%  4%  5%  4%  5%
  [libx264 @ 0x2316f40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 30% 16%  4%  5%  5%  6%  4%  5%
  [libx264 @ 0x2316f40] i8c dc,h,v,p: 54% 26% 15%  5%
  [libx264 @ 0x2316f40] Weighted P-Frames: Y:1.5% UV:0.9%
  [libx264 @ 0x2316f40] ref P L0: 87.9% 12.1%
  [libx264 @ 0x2316f40] ref B L0: 87.9% 12.1%
  [libx264 @ 0x2316f40] ref B L1: 97.8%  2.2%
  [libx264 @ 0x2316f40] kb/s:1890.83
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-08T10:01:50.560Z
Comments.Text: Try with recent versions. Both your ffmpeg versions are old.
Comments.UserDisplayName: Gyan
Tags: <video><ffmpeg><audio><conversion><h.264>
Title: Audio issue on concatenation of TS segments
UserDisplayName: nurmat
ThreadText: # Audio issue on concatenation of TS segments
  
  (Asked by: username_0 on 2016-12-08)
  
  I have downloaded segmented ts files, which i concatenate into mp4 file. The problem is that audio a bit faster than video progress. The problem is appeared when i re-convert concatenated mp4 file. How can i fix this audio issue?
  
  Concatenation ffmpeg command:
  
  ```
  ffmpeg -f concat -i hls.txt -c copy -bsf:a aac_adtstoasc hls.mp4 1> hls.log 2>&1
  
  ```
  
  Some concatenation output
  
  ```
  ffmpeg version N-76684-g1fe82ab Copyright (c) 2000-2015 the FFmpeg developers
    built with gcc 5.2.0 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
    libavutil      55.  6.100 / 55.  6.100
    libavcodec     57. 15.100 / 57. 15.100
    libavformat    57. 14.100 / 57. 14.100
    libavdevice    57.  0.100 / 57.  0.100
    libavfilter     6. 15.100 /  6. 15.100
    libswscale      4.  0.100 /  4.  0.100
    libswresample   2.  0.101 /  2.  0.101
    libpostproc    54.  0.100 / 54.  0.100
  [NULL @ 000000ebd70f13a0] start time for stream 2 is not set in estimate_timings_from_pts
  Input #0, concat, from 'hls.txt':
    Duration: N/A, start: 0.000000, bitrate: N/A
      Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
      Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 149 kb/s
      Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
  [mp4 @ 000000ebd7513aa0] Codec for stream 0 does not use global headers but container format requires global headers
  [mp4 @ 000000ebd7513aa0] Codec for stream 1 does not use global headers but container format requires global headers
  Output #0, mp4, to 'hls.mp4':
    Metadata:
      encoder         : Lavf57.14.100
      Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
      Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 149 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (copy)
    Stream #0:1 -> #0:1 (copy)
  Press [q] to stop, [?] for help
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
      Last message repeated 1 times
  [h264 @ 000000ebd7514460] decode_slice_header error
  [h264 @ 000000ebd7514460] no frame!
  [h264 @ 000000ebd7514460] non-existing PPS 0 referenced
  ...
  [h264 @ 000000ebd789d720] decode_slice_header error
  [h264 @ 000000ebd789d720] no frame!
  [NULL @ 000000ebd789bbc0] start time for stream 2 is not set in estimate_timings_from_pts
  frame= 9321 fps=5550 q=-1.0 Lsize=   97452kB time=00:06:19.95 bitrate=2101.1kbits/s    
  video:90227kB audio:6888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.346746%
  
  ```
  
  Here is my re-convert command:
  
  ```
  ffmpeg -y -i hls.mp4 -i watermark.png -filter_complex "scale=-2:'min(720,ih)',overlay=(main_w-overlay_w)-40:(main_h-overlay_h)-30" -codec:v libx264 -profile:v high -level 3.1 -preset fast -maxrate 1946k -bufsize 2500k -c:a copy -crf 20 -pix_fmt yuv420p -movflags +faststart output.mp4 1> output.log 2>&1
  
  ```
  
  Some output log:
  
  ```
  ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers
    built on Nov 16 2014 22:36:57 with gcc 4.8.2 (GCC)
    configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/man --docdir=/usr/doc/ffmpeg-2.4.3 --enable-gpl --enable-version3 --enable-avfilter --enable-avresample --enable-libass --enable-libdc1394 --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-postproc --enable-runtime-cpudetect --enable-vaapi --enable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --arch=x86_64 --enable-pic --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib64 -ldl -lssl -lcrypto -lz -lusb' --pkg-config-flags=--static
    libavutil      54.  7.100 / 54.  7.100
    libavcodec     56.  1.100 / 56.  1.100
    libavformat    56.  4.101 / 56.  4.101
    libavdevice    56.  0.100 / 56.  0.100
    libavfilter     5.  1.100 /  5.  1.100
    libavresample   2.  1.  0 /  2.  1.  0
    libswscale      3.  0.100 /  3.  0.100
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  0.100 / 53.  0.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hls.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf57.14.100
    Duration: 00:06:19.96, start: 0.000000, bitrate: 2101 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1946 kb/s, 24.54 fps, 50 tbr, 90k tbn, 50 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 148 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Input #1, png_pipe, from 'watermark.png':
    Duration: N/A, bitrate: N/A
      Stream #1:0: Video: png, rgba, 250x50, 25 tbr, 25 tbn, 25 tbc
  [libx264 @ 0x2316f40] using SAR=1/1
  [libx264 @ 0x2316f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
  [libx264 @ 0x2316f40] profile High, level 3.1
  [libx264 @ 0x2316f40] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=3 lookahead_threads=1 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1946 vbv_bufsize=2500 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'output.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.4.101
      Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, max. 1946 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
      Metadata:
        encoder         : Lavc56.1.100 libx264
      Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 148 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  Stream mapping:
    Stream #0:0 (h264) -> scale
    Stream #1:0 (png) -> overlay:overlay
    overlay -> Stream #0:0 (libx264)
    Stream #0:1 -> #0:1 (copy)
  Press [q] to stop, [?] for help
  frame=   38 fps=0.0 q=25.0 size=       4kB time=00:00:01.65 bitrate=  17.4kbits/s dup=3 drop=0    
  frame=   50 fps= 46 q=25.0 size=      20kB time=00:00:02.14 bitrate=  76.7kbits/s dup=3 drop=0    
  frame=   58 fps= 35 q=25.0 size=      75kB time=00:00:02.44 bitrate= 249.9kbits/s dup=3 drop=0    
  ...
  frame= 9478 fps= 13 q=25.0 size=   94544kB time=00:06:19.26 bitrate=2042.1kbits/s dup=175 drop=0    
  [mp4 @ 0x2316160] Starting second pass: moving the moov atom to the beginning of the file
  frame= 9496 fps= 13 q=-1.0 Lsize=   94901kB time=00:06:19.95 bitrate=2046.1kbits/s dup=175 drop=0    
  video:87673kB audio:6888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.359540%
  [libx264 @ 0x2316f40] frame I:64    Avg QP:25.22  size: 53069
  [libx264 @ 0x2316f40] frame P:5242  Avg QP:27.77  size: 13431
  [libx264 @ 0x2316f40] frame B:4190  Avg QP:29.21  size:  3813
  [libx264 @ 0x2316f40] consecutive B-frames: 21.7% 52.4% 17.8%  8.0%
  [libx264 @ 0x2316f40] mb I  I16..4: 15.5% 61.0% 23.5%
  [libx264 @ 0x2316f40] mb P  I16..4:  5.6%  9.5%  1.3%  P16..4: 41.7%  8.8%  4.0%  0.0%  0.0%    skip:29.0%
  [libx264 @ 0x2316f40] mb B  I16..4:  1.9%  1.6%  0.1%  B16..8: 29.8%  3.9%  0.3%  direct: 3.5%  skip:59.0%  L0:39.2% L1:55.5% BI: 5.3%
  [libx264 @ 0x2316f40] 8x8 transform intra:56.1% inter:70.6%
  [libx264 @ 0x2316f40] coded y,uvDC,uvAC intra: 34.0% 52.1% 12.3% inter: 11.3% 12.9% 0.6%
  [libx264 @ 0x2316f40] i16 v,h,dc,p: 23% 48% 14% 16%
  [libx264 @ 0x2316f40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 30% 25%  3%  3%  4%  5%  4%  5%
  [libx264 @ 0x2316f40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 30% 16%  4%  5%  5%  6%  4%  5%
  [libx264 @ 0x2316f40] i8c dc,h,v,p: 54% 26% 15%  5%
  [libx264 @ 0x2316f40] Weighted P-Frames: Y:1.5% UV:0.9%
  [libx264 @ 0x2316f40] ref P L0: 87.9% 12.1%
  [libx264 @ 0x2316f40] ref B L0: 87.9% 12.1%
  [libx264 @ 0x2316f40] ref B L1: 97.8%  2.2%
  [libx264 @ 0x2316f40] kb/s:1890.83
  
  ```
  
  **Tags:** video, ffmpeg, audio, conversion, h.264
  
  > **Comments:**
  > **username_1**: Try with recent versions. Both your ffmpeg versions are old.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-12-08. Score: 3
  
  Don't use the concat demuxer. Create a single ts file by concatenating the ts segments as a first step. Then run it through ffmpeg.
  
  i.e.
  `cat 1.ts 2.ts >all.ts`
  `ffmpeg -i all.ts -c copy all.mp4`
  
  > **Comments:**
  > **username_0**: I guess you mean concat protocol. I read that this method support only MPEG-1, MPEG-2 PS, DV containers. In my case, ts segments are h.264 container  
  > **username_2**: no, I mean exactly what I said (https://trac.ffmpeg.org/wiki/Concatenate#demuxer) h.264 is the codec, transport stream (ts) is the container. I don't know what you read, but you CAN concatenate ts segments.  
  > **username_0**: Yes, i got mixed up mp4 with h264. Your answer is incomplete a bit. I added -bsf:a aac_adtstoasc option and that's ok. [Here](http://ffmpeg.org/faq.html#Concatenating-using-the-concat-protocol-_0028file-level_0029) is another way of the concat protocol  
  
  ---
  
  