How to segment a video and then concatenate back into original one with ffmpeg
<p>I am surveying on distributed video transcoding with FFmpeg. I have found that there is a good script on  <a href="https://github.com/nergdron/dve/blob/master/dve" rel="noreferrer">https://github.com/nergdron/dve/blob/master/dve</a>.</p>

<p>The script mainly uses the <code>segment</code> and <code>concatenate</code> filters of FFmpeg. I want to do a simple test first. However, I can not split the video into segments and then concatenate back to original video (with the same codec). I have tried with the following command:</p>

<p>a. Chunk the video </p>

<pre><code>ffmpeg -fflags +genpts -i Test.avi -map 0 -codec copy -f segment -segment_format avi -v error chunk-%03d.seg
</code></pre>

<p>b. Building the chunking list:</p>

<pre><code>#!/bin/bash -e
set -e
echo "ffconcat version 1.0" &gt; concat.txt
for f in `ls chunk-*.seg | sort`; do
echo "file $f" &gt;&gt; concat.txt
done
</code></pre>

<p>c. Concatenate the chunks</p>

<pre><code>ffmpeg  -y -v error -i concat.txt -f concat -map 0 -c copy -f avi output.avi
</code></pre>

<p>Then when I run <code>ffprobe</code> I get the following message which says it is a non-interleaved AVI:</p>

<pre><code>    ffprobe version N-82301-g1bbb18f Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --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. 35.100 / 55. 35.100
  libavcodec     57. 66.101 / 57. 66.101
  libavformat    57. 57.100 / 57. 57.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 66.100 /  6. 66.100
  libswscale      4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
[avi @ 00000000028e3700] non-interleaved AVI
Input #0, avi, from 'output.avi':
  Metadata:
    encoder         : Lavf57.57.100
  Duration: 74:43:47.82, start: 0.000000, bitrate: 17 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 112 kb/s
</code></pre>

<p>I have tried a few other things without success. Any help would be greatly appreciated. Thanks in advance!! </p>